Want to Unzip your Zip file on Your ftp Server and don't Know How to do that then you can use below code.with this code easily unzip any zip file with in some sec only .
Now follow my instruction to know how to use this
- Open Notepad and copy/paste below code in it.
<?php
$zip = new ZipArchive;
$res = $zip->open('myfilename.zip');
if ($res === TRUE) {
$zip->extractTo('myfoldername/');
$zip->close();
echo 'ok';
} else {
echo 'failed';
}
?>
$zip = new ZipArchive;
$res = $zip->open('myfilename.zip');
if ($res === TRUE) {
$zip->extractTo('myfoldername/');
$zip->close();
echo 'ok';
} else {
echo 'failed';
}
?>
- Replace myfilename.zip with your uploaded zip file name which you want to extract/unzip on server .
- and myfoldername/ with folder/directory where you want to unzip.
- Then Save this File with any name but extension must be .php and upload it your server
- Now Open this uploaded php file in your browser it will automatically extract that zip file
Note:-Directory where you want Unzip that file must be with write permission better You Chmod it with write permission.
Now all done Enjoy ..if you like or any Problem with this code then comment below ...
0 comments:
Post a Comment