我想将一个tar文件解压到一个目录中,但是不知道该怎么做。 我可以将它提取到与tar文件相同的目录中,但无法提取到另一个文件夹中。
$filename = "homedir.tar";
exec("tar xvf $filename");
尝试了以下方法,但它并没有起作用(没有提取到任何内容):
exec("tar -C, homedir zxvf $filename");
更新:
这是我的文件内容:
# Absolute paths
$filepath = "/home/acc/public_html/test/test/homedir.tar";
$folderpath = "/home/acc/public_html/test/test/homedir";
# Check if folder exist
if(!is_dir($folderpath)) {
die('Folder does not exist');
}
# Check if folder is writable
if(!is_writable($folderpath)) {
die('Folder is not writable');
}
# Check if file exist
if(!file_exists($filepath)) {
die('File does not exist');
}
exec("tar -C $folderpath -zxvf $filepath");
没有错误,但是也没有压缩文件被解压缩。