unzip folder files using php code

unzip folder files using php code

unzip folder files using php code- image copied from http://berkleectmi.wordpress.com/

some time you want to extract files from a zip on a website but you didn’t have sufficient rights or cpanel to extract that , you have on;y ftp details only in that case you need a code to extract that zip. following can help you to do that.

$zip = new ZipArchive; if ($zip--->open('test.zip') === TRUE) {
 // using $_SERVER['DOCUMENT_ROOT'] if you don't know the where you are
 $zip->extractTo('/my/destination/dir/');
 $zip->close();
 echo 'ok';
 } else {
 echo 'failed';
 }