我正在laravel 5.2中处理cron作业,当我尝试从计划调用控制器功能时创建excel表获取错误。但在邮递员中运行良好。
ZipArchive::close(): Failure to create temporary: No such file or directory' in /var/www/html/Expenses/vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007.php:398
zipArchive的临时文件权限问题?
我将phpexcel表保存到目录(777)时出现上述错误。
$excel_path = 'SubmittedSheets/'.$userId.'-'.uniqid().'.xlsx';
$objWriter->save($excel_path);
需要在AWS Ec2 Linux for PHPExcel中保存excel文件的绝对路径。
$excel_path = '/var/www/html/MyProject/public/SubmittedSheets/'.$userId.'-'.uniqid().'.xlsx';
$objWriter->save($excel_path);
我在Mac OS系统上通过简单地取消注释线来解决它
;sys_temp_dir = "/tmp"
在php.ini
,即改为
sys_temp_dir = "/tmp"
应放置临时文件的目录。默认为系统默认值(请参阅sys_get_temp_dir)
不知道它尝试使用哪个目录作为默认目录,可能是/var/tmp
,我的Homebrew PHP安装似乎没有写入权限。
我尝试了很多东西,花了很多时间。 Ubuntu + Vesta + Nginx + Apache的解决方案在文件中:
:/home/admin/conf/web/your-domain.com.apache2.ssl.conf
像我的例子中那样设置tmp文件夹:
<Directory /home/admin/web/your-domain.com/public_html>
AllowOverride All
SSLRequireSSL
Options +Includes -Indexes +ExecCGI
php_admin_value open_basedir
/home/admin/web/your-domain.com/public_html:/tmp
php_admin_value upload_tmp_dir /tmp
php_admin_value session.save_path /tmp
</Directory>
别忘了重启apache服务