程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

HTTP header file not downloaded completely

发布于2023-05-25 21:36     阅读(242)     评论(0)     点赞(17)     收藏(5)


I am trying to download the file with http header but it will not download completly. The uploaded file size is 1 MB and the file download with my code 336 byte size only.

I am trying with below code

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

解决方案


I have solved this issue by just changing the filepath remove the path with SiteURL and provide the path from folder. Check code below,

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


所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接:http://www.phpheidong.com/blog/article/546153/38e354e38c7384e9c901/

来源:php黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

17 0
收藏该文
已收藏

评论内容:(最多支持255个字符)