爱情公寓3 11,免费论理电影,成人游戏免费下载
本文实例讲述了php readfile下载大文件失败的解决方法。分享给大家供大家参考,具体如下:
大文件有200多m,只下载了200k就提示下载完成,且不报错。
原因是php内存有限制,需要改为按块下载,就是把大文件切块后逐块下载。
if (file_exists($file)) { if (false!== ($handler = fopen($file, 'r'))) { header('content-description: file transfer'); header('content-type: application/octet-stream'); header('content-disposition: attachment; filename='.basename($file)); header('content-transfer-encoding: chunked'); //changed to chunked header('expires: 0'); header('cache-control: must-revalidate, post-check=0, pre-check=0'); header('pragma: public'); //header('content-length: ' . filesize($file)); //remove //send the content in chunks while(false !== ($chunk = fread($handler,4096))) { echo $chunk; } } exit; } echo "<h1>content error</h1><p>the file does not exist!</p>";
更多关于php相关内容感兴趣的读者可查看本站专题:《php文件操作总结》、《php网络编程技巧总结》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》
希望本文所述对大家php程序设计有所帮助。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
php的instanceof和判断闭包Closure操作示例
php数组函数array_push()、array_pop()及array_shift()简单用法示例
yii2.0框架实现上传excel文件后导入到数据库的方法示例
php使用goto实现自动重启swoole、reactphp、workerman服务的代码
网友评论