note 81096 deleted from function.delete by philip
| From: | philip@php.net | Date: | Wed, 11 Jun 2008 19:28:00 +0000 |
| Subject: | note 81096 deleted from function.delete by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-140360@lists.php.net to get a copy of this message | ||
Note Submitter: RisingKing
----
<?
$filename=stripslashes($_GET['file']);
if(file_exists("$filename"))
{
if(unlink("$filename"))
{
echo "File was successfully deleted";
}
else
{
echo "File was not deleted.";
}
}
else
{
echo "File does not exist.";
}
?>
This checks if the file exists, if the file exists it deletes the file and returns a message
confirming the deletion. If the file was not deleted, a message will be returned say the file was
not deleted. If the file does not exist, a message will be returned say the file doesn't exist.
To use the script just add at the end of the URL ?file={the file you want to delete}
Ex:
127.0.0.1/delete.php?file=New Text Document.txt
That will delete the file New Text Document.txt