【发布时间】:2014-04-08 12:37:45
【问题描述】:
我在 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);
}
}
请谁能帮我解决这个错误,感谢您的帮助!
【问题讨论】:
-
这不是错误,这是代码!你得到什么错误?
-
在 php.ini 中增加 PHP 允许的内存?
-
感谢您的回复。
-
您的代码所需的内存量超过了您在环境中分配的可用内存量。正如@D.Kasipovic 所说,您需要增加内存限制,或优化您的查询和循环,使其不需要太多内存。
-
如果 php.ini 中的 memory_limit 变量更改为 -1 会有什么影响/缺点。
标签: php codeigniter memory zip