PHP脚本下载超过2GB的图像ZIP


PHP Script for Downloading more than 2GB Image ZIP

在服务器上,我为图像创建了Zip文件,Zip文件的大小超过2gb。我想下载一个zip文件。有时文件下载停止或失败时,使用下面的脚本。我必须更改服务器变量..

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;
    }
}

试着在代码上方写两行:

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