...

View Full Version : Unlink File Question



Papajo
05-09-2009, 05:57 PM
Hi
I would like to be able to call this file delete script by using a button, just don't know how to add a function for this. Any help is appreciated. Joe







$file_delete = "A_Picture.jpg";
if (unlink($file_delete)) {
echo "The file was deleted successfully.", "\n";
} else {
echo "The specified file could not be deleted. Please try again.", "\n";
}

Killermud
05-09-2009, 07:17 PM
If you mean adding a button that once clicked will delete a file you need to have abit of HTML added, so just use this.



<?
if(isset($_POST['submit']{
$file_delete = "A_Picture.jpg";
if (unlink($file_delete)) {
echo "The file was deleted successfully.", "\n";
} else {
echo "The specified file could not be deleted. Please try again.", "\n";
}
}?>
<form method="post">
<input type="submit" name="submit" Value="Delete">
</form>

Hope this helps!

Papajo
05-09-2009, 07:57 PM
I just had to add a couple of bracket's but it works fine. Thanks Joe




if(isset($_POST['submit'])){



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum