2010-04-16 9 views
0

출력에 들어가고 내 사이트에서 파일을 저장하는 PHP 스크립트의 명령을 알고 싶습니다. 감사합니다사이트에서 파일 다운로드

+1

file_get_contents 당신이 사이트를 탐색하는 사용자에 대한 파일 다운로드를 시작하는 방법을 알고 싶습니다 건가요 필요? – Kazar

+3

죄송합니다. 원하시는 것이 분명하지 않습니다. 다른 단어 나 예를 들어 설명해 주시겠습니까? – deceze

+0

* (참조) * http://de2.php.net/manual/en/function.header.php (예제 1 다운로드 대화 상자 참조) – Gordon

답변

1

PHP 스크립트의 출력을 강제로 다운로드하는 방법에 대한 설명을 참조하십시오. 그것의

기본 사항은 다음과 같습니다

(고든의 코멘트에서 제공)를 추가로
// Set headers 
header("Cache-Control: public"); 
header("Content-Description: File Download"); 
header("Content-Disposition: attachment; filename=" + $filename); 
header("Content-Type: application/zip"); // or whatever the mime-type is 
              // for the file you want to download 
header("Content-Transfer-Encoding: binary"); 

// Read the file from disk 
readfile($full_path_to_file); 

는, 파일의 끝에서 PHP 문서 here

0

에 1 예를 참조하거나 클릭에 사용 파일을 추가 할 수 있습니다. ob_start()를 추가 할 수있는 파일의 맨 위에 문제가있는 수단을 사용하여 헤더가 있으면

 $filesh = "check.xls"; 

     header("Pragma: public"); 
     header("Expires: 0"); 
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
     header("Content-Type: application/force-download"); 
     header("Content-Disposition: attachment; filename=".basename($filesh)); 
     header("Content-Description: File Transfer"); 
     readfile($filesh); 

을 추가 할 수 있습니다. 기능

0

당신은 출력, 다른 사이트 또는 위치에서 내용을 점점 의미하는 경우이 당신이

관련 문제