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
    Jun 2006
    Location
    Birmingham, UK
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Delete running file

    Hi, i have a php page.

    Is it possible to delete the file itself whilst its running?

    For eg..

    Code:
    unlink("thispage.php");
    Doesnt work for me. Thanks.

  • #2
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    You could create a new file:
    PHP Code:
    $file = 'deletefile' . rand(0, 999) . 'php';
    while (file_exists($file)){
    $file = 'deletefile' . rand(0, 999) . 'php';
    }
    $fh = fopen($file, 'a+');
    fwrite($fh, '<?php unlink("' . $_SERVER['PHP_SELF'] . '"); ?>');
    header('Location: ' . $file);

  • #3
    New Coder
    Join Date
    Jun 2006
    Location
    Birmingham, UK
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oh nice idea! Thanks


  •  

    Posting Permissions

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