I\'m using PHPExcel to export some data to user in an excel file. I would like the script to send the excel file to the user immediately after it\'s creation. Here is my tes
It's caused by dir permission. Try to enter the final folder, then chmod -R 777 [folder_name]
. It should work :)
Excelent Friend Work for me in php 7.1.2 and work in PhpSpreadsheet, fix the same file.
PhpSpreadsheet/Writer/Excel2007.php
the solution is in de function save in Excel2007.php
if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') {
$pFilename = @tempnam(PHPExcel_Shared_File::sys_get_temp_dir(), 'phpxltmp');
Replace the second line with this:
$pFilename = dirname(__FILE__).'/'. rand(0, getrandmax()) . rand(0, getrandmax()) . ".phpxltmp";
thanks.
I´ve had the same error when I try run my php file, just change the in next line:
$objWriter->save("/dir1"."/".$file.".xlsx");
for this:
$objWriter->save(dirname(__FILE__)."/dir1"."/".$file.".xlsx");
add the the dir
path and it worked!!!.
In my case, I modify the permissions of the target folder to rwxrwxrwx (0777) and now works!
The most common cause of this error when saving to php://output is an open_basedir restriction that doesn't include a valid system's temp folder (e.g. /tmp
), or permissions for the system's temp folder... suhosin can also affect this, even when the obvious permissions appear to be set correctly.
A possible workround is to write the file to the filesystem in a directory that you know you do have full privileges to write, and then use readfile() to stream that file to php://output before deleting the file
This error happens also when trying to save a file into a folder that doesn't exist. Make sure the whole path exists.