Issue
I'm trying to save an excel file to a server, but what I really need is to send it as an email attachment, so I'm trying to store it in server and then to send it as an attachment. But I get an error with the browser, it says it cannot find the file path/to/file/sendExcell.php.
Send excel php is the file that I'm launching in the browser and it's being launched if I comment $objWriter->save(dirname(__FILE__).'stats.xlsx');
or if I change it to this other line:
$objWritter->save('php://output')
This is the code:
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
// We'll be outputting an excel file
header('Content-Type: application/xlsx');
header('Content-Disposition: attachment;filename="stats.xlsx"');
header('Cache-Control: max-age=0');
ob_end_clean();
$objWriter->save(dirname(__FILE__).'stats.xlsx');
print_r('ok');die; //never prints
I also cannot save it this way:
$objWriter->save();
It prints a white screen (removing the headers) and with the headers it prints the same error (cannot find the file)
Solution
Maybe You have not permission. If you use Linux try chmod 777.
Answered By - Vahe Galstyan Answer Checked By - Timothy Miller (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.