2014-01-29 4 views
0

:한 시간 다운로드 링크 및 대용량 파일

http://www.webvamp.co.uk/blog/coding/creating-one-time-download-links/

는 사용자가 파일 (1 회)를 다운로드 할 수 있습니다. 모든 것은 작은 파일들로 잘 작동합니다. 이제는 더 큰 파일 1.2 GB로 동일하게하려고합니다. 사용자가 파일을 다운로드하도록 강요하는 대신 스크립트는 파일에 대한 상대 패치를 보여줍니다! 스크립트를 수정하는 방법이나 서버 구성의 오류가 있습니까?

도움 주셔서 감사합니다.

답변

0

코드를 찾는 것은 메모리 제한 때문에 큰 파일에는 오류가 있다고 생각합니다. 스크립트는 전체 파일을 보내기 전에 메모리에있는 file_get_contents()을 통해 전체 파일을 읽습니다. 나는 1GB 파일> 것입니다 의심되는 메모리 문제가 발생합니다. download.php 스크립트에 다음 줄을 교체하십시오 :

  //get the file content 
      $strFile = file_get_contents($strDownload); 

      //set the headers to force a download 
      header("Content-type: application/force-download"); 
      header("Content-Disposition: attachment; 

filename=\"".str_replace(" ", "_", $arrCheck['file'])."\""); 

        //echo the file to the user 
        echo $strFile; 

에 :

header('Content-Description: File Transfer'); 
    header('Content-Type: application/octet-stream'); 
    header('Content-Disposition: attachment; filename='.basename($strDownload)); 
    header('Content-Transfer-Encoding: binary'); 
    header('Expires: 0'); 
    header('Cache-Control: must-revalidate'); 
    header('Pragma: public'); 
    header('Content-Length: ' . filesize($strDownload)); 
    ob_clean(); 
    flush(); 
    readfile($strDownload); 

이 도움이 될 수 있습니다. 매뉴얼에서

참고 : 에서 ReadFile(), 모든 메모리 문제를 제시 심지어 자신의

+0

덕분에, 큰 파일을 보낼 때, 그러나 didnt 한 도움 ... 작은 파일이 잘 다운로드하지만 큰의 경우되지 않습니다 디스플레이 파일을 찾을 수 없습니다. – user3249713

관련 문제