In a previous article we learned how to create compressed tar archives in php. Now lets do the reverse, that is extract tar.gz archives and get the files out.
The code to extract a tar.gz archive is very simple and uses PharData class. Here is an example
// 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');
The first step is to uncompress the tar.gz and convert into a .tar file. Next the .tar file is unpacked and file are copied inside a directory.
Thanx for your help its working for me to exract file from ftp account