如何用php保存服务器上的excel文件?

问题描述 投票:0回答:2

我正在尝试将excel文件保存到服务器,但我真正需要的是将其作为电子邮件附件发送,因此我尝试将其存储在服务器中,然后将其作为附件发送。但是我在浏览器中遇到错误,它说找不到文件路径/到/ file / sendExcell.php。发送excel php是我在浏览器中启动的文件,如果我评论$objWriter->save(dirname(__FILE__).'stats.xlsx');或者我将其更改为其他行,它将被启动:

$objWritter->save('php://output')

这是代码:

$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 

我也不能这样保存:

$ objWriter-)>保存(;

它打印一个白色的屏幕(删除标题)和标题,它打印相同的错误(找不到文件)

php phpexcel
2个回答
2
投票

也许你没有得到许可。如果你使用Linux试试chmod 777。


0
投票
$objWriter->save ( getcwd ().'/stats.xlsx')
© www.soinside.com 2019 - 2024. All rights reserved.