2017-05-29 65 views
1

我试图用http头下载文件,但它不会完全下载。上传的文件size is 1 MB和文件仅用我的代码336 byte大小下载。HTTP头文件没有完全下载

我用下面的代码

$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

我已经只是改变了文件路径删除路径与SiteURL,并提供从文件夹的路径来解决这个问题尝试。检查下面的代码,

$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;