2013-06-18 4 views
0

링크를 클릭하면 강제로 PDF를 다운로드하려고하지만 읽기 파일의 헤더 경고 및 이상한 문자가 계속 수신됩니다.서버에서 pdf 파일을 다운로드 할 수 없습니다.

<a> 태그 :

<p>The pdf file is large and can take a minute to download. 
You can <a href="/icisherbrooke/downloadAnnuaire.php">click here to download the pdf.</a></p> 

download.php 파일 :

<?php 

$fullpath = 'annuaire_2013-14_optimized3.pdf'; 

if(file_exists($fullpath)){ 
    header('Content-Description: File Transfer'); 
    header('Content-Type: application/octet-stream'); 
    header('Content-Disposition: attachment; filename="annuaire_2013-14_optimized3.pdf"'); 

    readfile($fullpath); 
    exit(); 
} 

?> 

내가 헤더와 ReadFile을가 echo "test"에 의해 대체

, 그것은 작동합니다.

다운로드 프롬프트 대신 download.php로 리디렉션됩니다. 여기 download.php에 대한 결과의 일부는 다음과 같습니다 오류가 표시

Warning: Cannot modify header information - headers already sent by (output started at /home/kanope/vhost_file/info-rapide.com/icisherbrooke/downloadAnnuaire.php:1) in /home/kanope/vhost_file/info-rapide.com/icisherbrooke/downloadAnnuaire.php on line 8 %PDF-1.6 %���� 1561 0 obj <> endobj 1575 0 obj <>/Filter/FlateDecode/ID[<0EC5F18608359D479CC3DB0FF72E23C8><997B135B48FBE541BDE876EE8BECFD9D>]/Index[1561 20]/Info 1560 0 R/Length 95/Prev 216592620/

+1

1 호선에 공백이있는 것 같습니다. 아마도 BOM 일 수 있습니다. – Jessica

+1

당신 말이 맞습니다. 실제로 BOM이었습니다. 메모장의 인코딩을 BOM없이 UTF8로 변경하고 새 파일이 작동합니다. 이 질문을 답으로 게시한다면 받아 들일 수 있습니다. 고맙습니다. – oliboon

답변

1

으로, 라인 1. 일부 출력 그것은 일반적으로 공백입니다있다. 공백이 보이지 않으면 BOM을 확인하십시오. :)

관련 문제