提取tar文件并在php中保留权限,而不使用exec函数


Extract tar file and preserve the permissions in php without using exec function

我正在使用的当前服务器禁用了exec函数。是否可以使用php脚本提取tar并保留权限?

您可以使用PharData类:

示例:Create a tar

$phar = new PharData('test.tar');
// add all files in the project
$phar->buildFromDirectory('/path/to/files');

示例:Unpack a tar

$phar = new PharData('test.tar');
// add all files in the project
$phar->extractTo('/path/to/files');