2017-05-29 8 views
1

httpヘッダーでファイルをダウンロードしようとしていますが、完全にダウンロードされません。アップロードされたファイルsize is 1 MBとファイルは私のコード336 byteのサイズでダウンロードされます。HTTPヘッダーファイルが完全にダウンロードされていません

私はちょうどファイルパスSiteURLでパスを削除し、フォルダからのパスを提供を変更することで、この問題を解決したコード

$attachment_location= "filename"; 
$filePath= "$siteURL/foldername/filename"; 
$file_content  = file_get_contents($filePath); 
header("Content-type: application/octet-stream"); 
header("Content-Disposition: attachment; filename=\"$attachment_location\""); 
echo $file_content; 
+0

この質問はあなたに答えるかもしれません。https://stackoverflow.com/questions/386845/http-headers-for-file-downloads –

答えて

0

以下にしようとしています。下記のコードをチェックしてください。

$attachment_location= "filename"; 
$filePath= "foldername/filename"; 
$file_content  = file_get_contents($filePath); 
header("Content-type: application/octet-stream"); 
header("Content-Disposition: attachment; filename=\"$attachment_location\""); 
echo $file_content; 
関連する問題