Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2008
    Posts
    28
    Thanks
    4
    Thanked 0 Times in 0 Posts

    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";


  • #2
    Regular Coder
    Join Date
    Mar 2009
    Location
    United Kingdom
    Posts
    161
    Thanks
    6
    Thanked 28 Times in 28 Posts
    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!

  • #3
    New Coder
    Join Date
    Oct 2008
    Posts
    28
    Thanks
    4
    Thanked 0 Times in 0 Posts
    I just had to add a couple of bracket's but it works fine. Thanks Joe


    PHP Code:
    if(isset($_POST['submit'])){ 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •