Web Analytics Made Easy -
StatCounter Delete running file - CodingForum

Announcement

Collapse
No announcement yet.

Delete running file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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.
    http://www.bfe2142.com

  • #2
    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);

    Comment


    • #3
      oh nice idea! Thanks
      http://www.bfe2142.com

      Comment

      Working...
      X