unzip files on server

by MD on 2009/11/01

To unzip any archive on server, just execute following script on your server.

<?php
system('unzip dak.zip');
echo "<p>If you dont see errors, files unzipped successfully";
?>

Here instead of dak.zip, write name of file you wish to unzip.

or if you wish to unzip files to a particular destination, then following code can be used

<?php
$zip = new ZipArchive;
if ($zip->open('dak.zip') === TRUE) {
    $zip->extractTo('dest/d1/');
    $zip->close();
    echo 'ok';
} else {
    echo 'failed';
}
?>

You may also like:

Leave a Comment

Previous post:

Next post: