2014-04-08 121 views
1

我在CodeIgniter中工作。我所試圖做的就是下載由ZIP類笨創建的zip文件,我得到這個錯誤:CodeIgniter Zip Class:允許的內存耗盡

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 30381518 bytes) in ..\system\core\Output.php on line 366 

我的PHP代碼:

foreach ($attachments as $attachment) { 
     if ($attachment->type === 'file') { 
      $data = @file_get_contents($uploadDirectory . $attachment->fullPath . DIRECTORY_SEPARATOR . $attachment->physicalName); 
      $attachment->location = ltrim($attachment->location, '/'); 
      $fileName = $attachment->location ? $attachment->location . DIRECTORY_SEPARATOR . $attachment->name : $attachment->name; 
      $this->zip->add_data($fileName, $data); 
     } 
    } 

請誰能幫我解決此錯誤,並感謝您的任何幫助!

+0

這不是錯誤,這是代碼!你得到的錯誤是什麼? – sunny

+1

在php.ini中增加允許的PHP內存? –

+0

感謝您的回覆。 –

回答

1

通過

ini_set('memory_limit', '-1');改變memory_limit的覆蓋默認PHP memory limit.

,或者使用所以儘量擔心,

使這兩條線後。 它開始工作

; Determines the size of the realpath cache to be used by PHP. This value should 
; be increased on systems where PHP opens many files to reflect the quantity of 
; the file operations performed. 
; http://php.net/realpath-cache-size 
realpath_cache_size = 16k 

; Duration of time, in seconds for which to cache realpath information for a given 
; file or directory. For systems with rarely changing files, consider increasing this 
; value. 
; http://php.net/realpath-cache-ttl 
realpath_cache_ttl = 120 

enter image description here

+0

如果php.ini中的memory_limit變量更改爲-1 –

+0

,那麼您將告訴服務器僅使用所需的所有內存,會有什麼影響/缺點? –

+0

這是正確的?請任何人都可以幫我解決這個錯誤! –

相關問題