how to untar a file with tar.gz extension in php script. i have written a php script for uploading a tar.gz file amongst many files. i have to untar this file. how will the command be like?

till now what i have done is - consider for uploading i have given this path
$path="/usr/local/apache/htdocs/mydir".$_HTTP_POST_FILES[0];
since only thing i know is the $path and not the file name hence
$output=shell_exec("gunzip {$path}");( this command is succesful)
my question is now how to proceed after this?
thanks in advance

Recommended Answers

http://www.freebsddiary.org/untar.php

You need to untar the file that has been unzipped, see above link.

Jump to Post

All 4 Replies

where are you all ? SOS

how would the syntax be? file name is not known but while uploading the path is known. my php script is not implementing the tar command

here is the solution. If you don't know the filename nad it is stored in some php variable
let $filename=x.tar.gz

shell_exec("cd destination_directory; gunzip {$filename}| tar xf -;");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.