duankuai6991 2014-08-04 10:18
浏览 517
已采纳

PHPExcel在保存时生成500错误

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 = 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.

I've tried changing the file name to just '1.xls' so it's not an issue with 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?

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)

Info: PHP version 5.3.10 Windows Server 2008 IIS 7.5

  • 写回答

1条回答 默认 最新

  • douhuocuo9012 2014-08-04 11:42
    关注

    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.

    I am kinda certain that an upgrade to a newer PHP version will solve the issues.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?