2014-03-24 67 views
1

在服務器上,我爲圖​​片創建了Zip文件。zip的大小大於2 GB。我想下載zip文件..有時使用下面的腳本文件下載停止或失敗。我不得不改變服務器變量..下載超過2GB圖片的PHP腳本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; 
    } 
} 
+0

**請注意,客戶端可以下載任何文件服務器可以讀**你應該!在你的問題中告訴「停止」和「失敗」是什麼意思。抑制錯誤並不是一個好習慣,就像在@fopen中一樣。 – Raffaele

回答

0

通過寫下面兩行代碼上面的嘗試:

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

我已經在varaibles下面添加.. ini_set('upload_max_filesize','5000M'); ini_set('post_max_size','10M'); ini_set('max_input_time',100000); –