Yesterday I started playing with the Kartik ExportMenu Plugin. Everything works fine in my local machine but when I uploaded it to the server I started getting a strange error in Chrome and Firefox. In Safari works fine.
2017-02-28 17:28:20 [190.100.143.19][1][gd2de617ahfvilgrmarav551e3][error][PHPExcel_Writer_Exception]
exception 'PHPExcel_Writer_Exception' with message
'Could not close zip file php://output.' in
/var/sentora/hostdata/zadmin/public_html/prod/admin/vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007.php:389
This error is triggered when I try to export the data of my gridView to any kind of extension using the plugin. I suppose that it happens when the plugin tries to save the file to the rute “php://output” and fails because of missing permissions but I don’t really know how can I change this.
The server is Ubuntu mounted in Amazon Web Services using Sentora.
Ok, just in case anyone is having this problem. I solved this by changing the default folder to which the exported reports are being saved. Then I had to set the permissions of that folder to 777 and it worked. So first:
<?
$folder = '@webroot/reports';
$linkPath = '/reports';
echo ExportMenu::widget([
'dataProvider' => $dataProvider,
'columns' => $gridColumns,
'fontAwesome' => true,
'target'=>ExportMenu::TARGET_SELF,
'showConfirmAlert'=>false,
'folder'=> $folder,
'linkPath'=> $linkPath,
'stream' => false, // this will automatically save the file to a folder on web server
'streamAfterSave' => true, // this will stream the file to browser after its saved on the web folder
'deleteAfterSave' => true, // this will delete the saved web file after it is streamed to browser,
'exportConfig' => [
ExportMenu::FORMAT_PDF => false
]
]);
?>
And after that go into the terminal, find the folder and: