我在CodeIgniter工作。我想要做的是下载由CodeIgniter的ZIP类创建的zip文件,我收到此错误:
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 :(得分:1)
通过
更改memory_limit ini_set('memory_limit', '-1');
会覆盖默认的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