2011-09-17 24 views
4

我要處理大文件(1-2GB)下載使用PHP腳本,發現兩種方法來做到這一點:如何讀取大文件和輸出它用PHP

  1. 與file_get_contents()函數
  2. 與ReadFile的()

,並使用這個實現:

header('Content-type: ' . $string); 
header('Content-disposition: attachment; filename=' . $info['filename']); 
$file = file_get_contents($filename); 
echo $file; 
or 
readfile($filename); 

但時間過長輸出的文件。我猜想在輸出開始之前,整個文件必須被重新分配。 當指出文件的確切位置時,它會更快。然後它幾乎立即開始輸出。

我正在尋找解決方案來傳輸文件或其他東西。有任何想法嗎?

+0

「這是時更快點的文件的確切位置?」 –

回答