CodeIgniter:允许内存耗尽 [英] CodeIgniter: Allowed memory exhausted

查看:68
本文介绍了CodeIgniter:允许内存耗尽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在CodeIgniter中工作。我想做的是读取Excel文件并将其保存到数据库。要读取Excel文件,我正在使用此库。上传后,在读取Excel文件时,出现以下错误:

I am working in CodeIgniter. What I am trying to do is reading an Excel file and saving to a database. To read the Excel file, I am using this library. After uploading, while reading the Excel file, I am getting this error:


致命错误:允许的内存大小为134217728字节已用尽(尝试在第430行/home/webscwi1/public_html/projects/OnlineExam/application/libraries/excel_reader.php中分配71个字节)

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 71 bytes) in /home/webscwi1/public_html/projects/OnlineExam/application/libraries/excel_reader.php on line 430

,我可以将内存大小从12Mb更改为512Mb,但仍然出现相同的错误。我不知道确切的错误是什么,我想知道这是服务器错误还是代码中的问题。

Anyhow, I can change the memory size from 12Mb to 512Mb, I'm still getting the same error. I don't know what is the exact error and I want to know whether this is a server error or a problem in the code.

其他信息:如果我上传了15行的文件,它工作正常,但是如果我在Excel中上传90行,则会出现此错误:

Additional info: If I upload the file with 15 rows, it's working fine, but if I upload with 90 rows in Excel I am getting this error:

 $this->load->library('excel_reader');
 $this->excel_reader->read('question/'.$filename);
 $worksheet = $this->excel_reader->worksheets[0];

感谢所有人。

推荐答案

您应该增加内存限制:


  • 编辑php.ini文件

  • editing your php.ini file

内存限制= 512M

memory_limit = 512M

OR


  • 在脚本顶部包含此行

  • including this line on the top of your script

ini_set( memory_limit, 512M );

ini_set("memory_limit","512M");

您还应该检查以下行是否在您的.htaccess文件中:

You should also check if this lines are on your .htaccess:

php_value memory_limit <value>
php_value upload_max_filesize <value>

它们的值覆盖php配置。因此,它们应该反映您的需求,或者只是被删除。

Their values override the php configuration. So they should reflect your needs, or simply be removed.

这篇关于CodeIgniter:允许内存耗尽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆