当下载文件大于12 MB,但成功下载文件小于12 MB时,我在php中下载文件时遇到问题。 这是我的代码:
if(isset($_REQUEST["file"])){
$file = urldecode($_REQUEST["file"]); // Decode URL-encoded string
if(file_exists($file)) {
$fp = fopen($file, "rb");
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Content-Transfer-Encoding: binary');
header('Connection: Keep-Alive');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header("Cache-Control: public");
header('Pragma: public');
header('Content-Length: ' . filesize($file));
set_time_limit(0);
readfile($file);
ob_end_clean();
die(fpassthru($fp));
fclose($fp);
exit;
}
}
问题已解决。只需删除文件名的符号字符即可。