laravel PHPExcel 在保存时生成 500 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25116468/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHPExcel generates 500 error on save
提问by Ben Green
I've just uploaded a set of code from my development server to my live one, and PHPExcel has started just generating a 500 error when i try to save anything. the code is below (Note: this all worked fine on the dev server, and both PHPExcel and Laravel work fine when transitioning between the two for other applications)
我刚刚将一组代码从我的开发服务器上传到我的实时服务器,当我尝试保存任何内容时,PHPExcel 已经开始生成 500 错误。代码如下(注意:这在开发服务器上一切正常,PHPExcel 和 Laravel 在两者之间转换时都可以正常工作以用于其他应用程序)
$PHPExcel = new PHPExcel;
$filename = 'Companies_Export_'.Session::getId().'.xls';
$file = public_path().'/_assets/exports/'.$filename;
//$fp = fopen($file, 'w');
$objWriter = PHPExcel_IOFactory::createWriter($PHPExcel, 'Excel5');
$objWriter->save($file);
I've removed the code to populate the file, in case it was a filesize issue.
我已经删除了填充文件的代码,以防它是文件大小问题。
I've used fopen to test if the application has write access to the directory, and that creates a new file with the correct name in the correct place, so that's fine too.
我已经使用 fopen 来测试应用程序是否具有对该目录的写访问权限,并在正确的位置创建一个具有正确名称的新文件,所以这也很好。
I've tried changing the file name to just '1.xls' so it's not an issue with Session::getId()
我已经尝试将文件名更改为“1.xls”,因此 Session::getId() 不是问题
If i comment out the $objWriter->save($file); line, it all works fine, just obviously doesn't save, and if i put garbage in as the parameter instead of a legitimate directory/filename, it still just 500's, so indicating PHPExcel must be failing while compiling the file or something?
如果我注释掉 $objWriter->save($file); 行,一切正常,只是显然没有保存,如果我把垃圾作为参数而不是合法的目录/文件名,它仍然只是 500,所以表明 PHPExcel 在编译文件时一定失败了还是什么?
I'm at a loss now, no matter what i do it won't show me an error, it just throws a 500 page with no info (detailed error page just says php fastcgi process exited unexpectedly or similar)
我现在不知所措,无论我做什么它都不会向我显示错误,它只会抛出一个没有信息的 500 页(详细的错误页面只是说 php fastcgi 进程意外退出或类似)
Info: PHP version 5.3.10 Windows Server 2008 IIS 7.5
信息:PHP 版本 5.3.10 Windows Server 2008 IIS 7.5
回答by Daniel W.
The reason we don't get a useful error message is because PHP (process exited unexpectedly
) itself crashes before beeing able to drop a note on the reason for its crash. Thus it can hardly be solved by PHP scripting due to PHP internal error.
我们没有收到有用的错误消息的原因是因为 PHP ( process exited unexpectedly
) 本身在能够删除崩溃原因之前就崩溃了。因此,由于 PHP 内部错误,它几乎无法通过 PHP 脚本来解决。
I am kinda certain that an upgrade to a newer PHP version will solve the issues.
我有点确定升级到较新的 PHP 版本会解决这些问题。