
First let’s create a simple form that will allow us to browse our computer and upload a zip file.
Now comes the uploader function:
open($target_path);
if ($x === true) {
$zip->extractTo("/home/var/yoursite/httpdocs/"); // change this to the correct site path
$zip->close();
unlink($target_path);
}
$message = "Your .zip file was uploaded and unpacked.";
} else {
$message = "There was a problem with the upload. Please try again.";
}
}
?>
To make sure the success and error messages appear, we will also have to add to short pieces of PHP code:
$message"; ?>
Putting it all together into a PHP file would look like this:
open($target_path);
if ($x === true) {
$zip->extractTo("/home/var/yoursite/httpdocs/"); // change this to the correct site path
$zip->close();
unlink($target_path);
}
$message = "Your .zip file was uploaded and unpacked.";
} else {
$message = "There was a problem with the upload. Please try again.";
}
}
?>
Untitled Document
$message"; ?>
Zip File Icon: Ritesh Ranjan


