我有一段代码可以在许多服务器上运行良好。 它用于通过php文件的readfile文件下载文件。通过php函数下载大文件readfile不起作用
但是在一台特定的服务器中,它不适用于大于25mb的文件。
下面是代码:
$sysfile = '/var/www/html/myfile';
if(file_exists($sysfile)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="mytitle"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($sysfile));
ob_clean();
flush();
readfile($sysfile);
exit();
当我尝试下载一个文件小于25MB的是没有问题的,当文件较大,下载的文件是0字节。
我试过了函数read()和file_get_contents,但问题仍然存在。
我的php版本是5.5.3,内存限制设置为80MB。 错误报告已打开,但即使在日志文件中也没有显示错误。
什么是'80mo'? – PeeHaa
首先通过PHP传递这些文件的原因是什么? –
对不起80mo是80MB(兆字节) – Jiwoks