Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-09-2009, 04:57 PM   PM User | #1
Papajo
New Coder

 
Join Date: Oct 2008
Posts: 28
Thanks: 4
Thanked 0 Times in 0 Posts
Papajo is an unknown quantity at this point
Unlink File Question

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





PHP Code:
$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";

Papajo is offline   Reply With Quote
Old 05-09-2009, 06:17 PM   PM User | #2
Killermud
Regular Coder

 
Join Date: Mar 2009
Location: United Kingdom
Posts: 161
Thanks: 6
Thanked 28 Times in 28 Posts
Killermud is on a distinguished road
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.

PHP Code:
<?
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!
Killermud is offline   Reply With Quote
Old 05-09-2009, 06:57 PM   PM User | #3
Papajo
New Coder

 
Join Date: Oct 2008
Posts: 28
Thanks: 4
Thanked 0 Times in 0 Posts
Papajo is an unknown quantity at this point
I just had to add a couple of bracket's but it works fine. Thanks Joe


PHP Code:
if(isset($_POST['submit'])){ 
Papajo is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:47 AM.


Advertisement
Log in to turn off these ads.