【发布时间】:2017-09-15 20:04:52
【问题描述】:
我正在尝试使用 PHPExcel 将 csv 导入我的应用程序,以便将数据加载到表中。当文件达到 2 meg+ 时,代码将失败。
我在 WAMP64 上运行 Laravel。失败的代码是:
$objPHPExcel = PHPExcel_IOFactory::load(Input::file('file')->getRealPath());
错误信息是:
ErrorException: file_get_contents(C:\wamp\www\imax\public): failed to open stream: Permission denied in C:\wamp\www\imax\vendor\phpoffice\phpexcel\Classes\PHPExcel\Shared\OLERead.php:85
我知道这是大小问题,因为当文件为 2048K 时,代码可以正确完成。我可以在文件中添加一个字符,将其推到 2049K,但它失败了。所以这不是权限问题。
OLERead.php 中失败的行是:
// Get the file identifier
// Don't bother reading the whole file until we know it's a valid OLE file
$this->data = file_get_contents($sFileName, FALSE, NULL, 0, 8);
Wampserver 3.0.6
PHP 7.0.10
【问题讨论】:
-
您是否尝试过在 php.ini 文件中更新
memory_limit?还有一条超时线和其他一些我会“向上”的线,但我不记得了。这可能会有所帮助:stackoverflow.com/questions/3829403/… -
内存限制为 512M。发现错误后加倍,没有变化。