Delete an uploaded file using php - unlink() - PHP Views : 1171
Tagged in : PHP
Send mail vote down 0 vote down 0

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';
}
?>
By - Sanju, On - 2010-06-24




    Login to add Comments .