通过php下载文件失败
我试图通过php下载一个zip文件 但下载突然中断 代码如下:通过php下载文件失败,php,Php,我试图通过php下载一个zip文件 但下载突然中断 代码如下: <?php $zip_file="uploads/".$path; header('Content-type: application/zip'); header('Content-disposition: filename="'. $zip_file. '"'); header('Content-length:'. filesize($zip_file)); readfile($zip_file); exit(); ?&g
<?php
$zip_file="uploads/".$path;
header('Content-type: application/zip');
header('Content-disposition: filename="'. $zip_file. '"');
header('Content-length:'. filesize($zip_file));
readfile($zip_file);
exit();
?>
我相信您在这一行中遗漏了关键词“附件”:
header('Content-disposition: filename="'. $zip_file. '"');
因此,它应该是:
header('Content-disposition: attachment; filename="'. $zip_file. '"');
给你。我已经每次都使用这个代码了
<?php
$zip_file = "uploads/".$path;
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($zip_file));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
readfile($zip_file);
exit;
?>
是否检查了错误?是否收到了超时形式的错误?我可以想象,下载50-100 mb可能需要比ini文件中设置的最大执行时间更长的时间,在max execution time
Dup下,我已经使用过它了,它已经建议使用另一个