我正在尝试将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");
没有错误,但也没有任何东西正在解压缩.