PharData extractTo方法无法在Linux环境中提取.tar.gz [英] PharData extractTo method failed to extract .tar.gz on linux environment
问题描述
我想将.tar.gz文件提取到特定的文件夹中.我已经使用cURL从MailChimp批处理操作下载.tar.gz文件.我已经使用下面的代码来提取tar文件.
I would like to extract .tar.gz file into the particular folder. I have used cURL to download the .tar.gz file from MailChimp batch operation. I have used below code to extract tar file.
$phar = new \PharData('upload/test.tar.gz');
$phar->extractTo('upload/',null, true);
它正在Windows环境下工作.但是在Linux(Ubuntu)上,运行上述代码时出现以下错误.
It is working on windows environment. But on Linux(Ubuntu), I got below error when to run above code.
Uncaught exception 'PharException' with message 'Extraction from phar "upload/test.tar" failed: Cannot extract ".", internal error'
我已经为上传文件夹设置了默认的apache用户和组权限.
I have already set default apache user and group permission for upload folder.
sudo chown -R www-data:www-data upload/
PHP版本:5.6.24
PHP Version: 5.6.24
我附有示例.tar.gz文件: http://www. simbanic.com/_projects/test/05c902076e.tar.gz
I have attach sample .tar.gz file: http://www.simbanic.com/_projects/test/05c902076e.tar.gz
推荐答案
我对MailChimp批处理响应存档有相同的问题. 愚蠢的解决方案,但是有效...
I had the same problem with MailChimp batch response archive. Stupid solution, but it works...
$p = new PharData($tarGzArchive, RecursiveDirectoryIterator::SKIP_DOTS);
$p->convertToData(Phar::ZIP);
$zip = new ZipArchive;
$res = $zip->open($createdZipArchive);
if ($res === TRUE) {
$zip->extractTo($destinationPath);
$zip->close();
}
这篇关于PharData extractTo方法无法在Linux环境中提取.tar.gz的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!