简体   繁体   English

PHP脚本,用于下载2GB以上的图像ZIP

[英]PHP Script for Downloading more than 2GB Image ZIP

On the Server I created Zip file for images..Size of zip is more than 2 GB. 在服务器上,我为图​​像创建了Zip文件。.zip的大小超过2 GB。 I want to download zip file.. Some times file downloading stops or fails when using below script. 我想下载zip文件。有时使用以下脚本时文件下载会停止或失败。 I had change server variables.. 我更改了服务器变量。

if (!$filename) {
    // if variable $filename is NULL or false display the message
    echo $err;
} else {
    // define the path to your download folder plus assign the file name
    $ordercode = $_GET['ordercode'];
    $refId = $_GET['refId'];        

    $path = 'files/'.$refId.'/'.$ordercode.'/'.$filename;

    // check that file exists and is readable
    if (file_exists($path) && is_readable($path)) {
        // get the file size and send the http headers
        $size = filesize($path);
        header('Content-Type: application/octet-stream');
        header('Content-Length: '.$size);
        header('Content-Disposition: attachment; filename='.$filename);
        header('Content-Transfer-Encoding: binary');

        // open the file in binary read-only mode
        // display the error messages if the file can´t be opened
        $file = @ fopen($path, 'rb');
        if ($file) {
            // stream the file and exit the script when complete
            fpassthru($file);
            exit;
        } else {
            echo $err;
        }
    } else {
        echo $err;
    }
}

Try it by writing below two lines above your code: 通过在代码上方的两行下面编写代码来进行尝试:

ini_set('max_execution_time', 10000);//you can change this value
ini_set("memory_limit", "6400M");//you can change this value

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM