Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过php下载文件失败_Php - Fatal编程技术网

通过php下载文件失败

通过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文件 但下载突然中断 代码如下:

<?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下,我已经使用过它了,它已经建议使用另一个