I am trying to unzip a tar file into a directory, but have no idea how to do this. I can extract it to the same directory as the tar file, but not to another folder.
$filename = "homedir.tar";
exec("tar xvf $filename");
We tried the following, but it does not work (nothing is retrieved):
exec("tar -C, homedir zxvf $filename");
Update:
This is the contents of my file:
$filepath = "/home/acc/public_html/test/test/homedir.tar";
$folderpath = "/home/acc/public_html/test/test/homedir";
if(!is_dir($folderpath)) {
die('Folder does not exist');
}
if(!is_writable($folderpath)) {
die('Folder is not writable');
}
if(!file_exists($filepath)) {
die('File does not exist');
}
exec("tar -C $folderpath -zxvf $filepath");
No errors, but nothing is unpacked.
source
share