解决PHP下载文件时因时文件太大而报404错误

set_time_limit(0);
ini_set('memory_limit', '512M');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
ob_end_clean();
readfile($file);

主要注意前面2个设置(根据情况自己设置内存大小)和 ob_end_clean();函数的调用。

原文地址:https://www.cnblogs.com/zeze/p/6307194.html