Jump to content

Extracting filename.tar.gz on server


pwired
 Share

Recommended Posts

Ok,

how do you extract a tar.gz file on an on-line server, e.g. filename.tar.gz

without using CPanel ?

My hoster does NOT provide shell access and PHP is executed in safe mode.

And this code does NOT work either:

< ?
system(\"tar -xvfz filename.tar.gz\");
?>

PHP Scripts working with pclzip.lip.php do not work either with .tar.gz (error: can not find end of archive!)

these scripts only work with zip files packed with 7zip or winrar.

Yes I could dump my hoster and look for one who gives shell access, but for the moment

I think it would work with the Pear class Archive_Tar

What would be a php test script to check if Pear is enabled on a server

and php code that calls the Archive_Tar class to extract filename.tar.gz ?

Anyone ?

Link to comment
Share on other sites

Did you try http://www.php.net/manual/en/phardata.extractto.php ?

On my host, this seems to be enabled, i.e. I see it listed when I do phpinfo().

Seems to be pretty easy to use. Example I found somewhere:

// decompress from gz
$p = new PharData('files.tar.gz');
$p->decompress(); // creates files.tar
 
// unarchive from the tar
$phar = new PharData('files.tar');
$phar->extractTo('new_dir'); 
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...