How to delete current file on exit (in php?) -
i know there temp file function, use create , delete file function on entering , exit user (deletes on exit). tried use both none worked,
first:
<?php $link = $_server['server_name'] . dirname(__file__); printf("%s\n", $link); array_map('unlink', glob("$link/*.php")); ?>
2nd:
<?php $filee = "http://$_server[http_host]$_server[request_uri]"; printf("%s\n", $link); unlink(realpath($filee)); ?>
you cannot delete (or unlink
) http urls. instead need delete files.
$link = "/tmp/foo.tmp"; unlink($link);
or, delete php files in directory of current file (credit @deadooshka above the top comment on php unlink
page ):
array_map('unlink', glob(__dir__ . '/*.php'));
you notice not prepending $_server['server_name']
onto beginning of path.
Comments
Post a Comment