Delete an uploaded file using php - unlink()
by Sanju[ Edit ] 2010-06-24 18:23:28
Delete an uploaded file using php - unlink()
The following link will help you to unzip/extract a file using php.
Unzip/Extract an uploaded file using php
and here the following code will help you to delete the uploaded file.
After unzip the file just use unlink() function after $zip->close(); to delete the file,
unlink($zip_file_name.zip);
Example:
<?php
$zip = new ZipArchive;
$res = $zip->open('zip_file_name.zip');
if ($res === TRUE) {
$zip->extractTo('dir_name/'); //will extract the file
$zip->close();
unlink(zip_file_name.zip); //will delete the file
echo 'Extracted';
} else {
echo 'Failed to Extract';
}
?>