Php 一次性下载链接和大型文件

Php 一次性下载链接和大型文件,php,time,download,Php,Time,Download,我正在使用以下脚本: 允许用户下载文件(一次)。使用小文件时一切都正常。现在我也在尝试做同样的事情,但是使用更大的文件1.2GB。脚本并没有强迫用户下载文件,而是显示文件的相关补丁!是否有任何方法可以修改脚本或它的错误服务器配置 谢谢你的帮助 查找代码时,由于内存限制,我认为它在大文件上失败。在发送之前,脚本通过file\u get\u contents()读取内存中的整个文件。我怀疑,>1Gb文件会导致内存问题。 尝试替换download.php脚本中的以下行: //

我正在使用以下脚本:

允许用户下载文件(一次)。使用小文件时一切都正常。现在我也在尝试做同样的事情,但是使用更大的文件1.2GB。脚本并没有强迫用户下载文件,而是显示文件的相关补丁!是否有任何方法可以修改脚本或它的错误服务器配置


谢谢你的帮助

查找代码时,由于内存限制,我认为它在大文件上失败。在发送之前,脚本通过
file\u get\u contents()
读取内存中的整个文件。我怀疑,>1Gb文件会导致内存问题。 尝试替换download.php脚本中的以下行:

            //get the file content
            $strFile = file_get_contents($strDownload);

            //set the headers to force a download
            header("Content-type: application/force-download");
            header("Content-Disposition: attachment; 

filename=\"".str_replace(" ", "_", $arrCheck['file'])."\"");

                    //echo the file to the user
                    echo $strFile;
致:

这可能会有所帮助


手册中的注意事项:readfile()本身不会出现任何内存问题,即使在发送大文件时也是如此

谢谢,但没有帮助。。。小文件可以下载,但如果是大文件,则显示文件找不到
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($strDownload));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($strDownload));
    ob_clean();
    flush();
    readfile($strDownload);