php数据致命错误
我现在正在从aws下载一个tar.gz文件到本地机器上。我想把它解压并解压缩以阅读内容。使用文件位置创建新的PharData对象时出错:php数据致命错误,php,tar,gzip,Php,Tar,Gzip,我现在正在从aws下载一个tar.gz文件到本地机器上。我想把它解压并解压缩以阅读内容。使用文件位置创建新的PharData对象时出错: Fatal error: Uncaught exception 'UnexpectedValueException' with message 'unable to create temporary file for decompression of gzipped phar archive "/Applications/XAMPP/xamppfiles/h
Fatal error: Uncaught exception 'UnexpectedValueException' with message
'unable to create temporary file for decompression of gzipped phar archive
"/Applications/XAMPP/xamppfiles/htdocs/NB/admin/temp/ea975d07f1-response.tar.gz"'
in /Applications/XAMPP/xamppfiles/htdocs/NB/admin/mcAdvanced.php:28 Stack trace: #0
/Applications/XAMPP/xamppfiles/htdocs/NB/admin/mcAdvanced.php(28):
PharData->__construct('./temp/ea975d07...') #1 {main}
thrown in /Applications/XAMPP/xamppfiles/htdocs/NB/admin/mcAdvanced.php on line 28
我的php代码是:
file_put_contents("./temp/ea975d07f1-response.tar.gz", fopen($response_body_url, 'r'));
$phar = new PharData('./temp/ea975d07f1-response.tar.gz'); //Error here-line28
我认为权限是正确的。我可以手动解压和查看。有人有什么建议吗
谢谢
哪个用户运行Apache进程?用exec'whoami'测试它。我想这只是$服务器[APP\u POOL\u ID]的权限问题。授予此标识读写权限。您的Web服务器需要对操作系统的$TEMP目录具有写访问权限,才能提取PHAR文件 用于查看这是什么目录,以便应用正确的权限
或者,您可以指定Web服务器已经有权访问的另一个目录作为PHP的临时目录。这是在使用超过普通大小的phar归档文件进行压缩时的常见问题。该错误源于php_stream_fopen_tmpfile失败时似乎会触发的错误,而php_stream_fopen_tmpfile只是该错误的别名。这个电话失败的原因目前还不清楚。使用sys_get_temp_dir显示temp位于/tmp,它具有正确的权限1777和足够的空间 解决此问题的方法是不压缩归档文件。我认为这不是一个很好的答案,然而,这在phar是一个长期存在的问题,我不会为短期解决方案屏住呼吸