lovephp Posted November 17, 2012 Share Posted November 17, 2012 guys how do i unlink a php file right after i access it. say i visit the file like www.somesite.com/file.php now the moment i access the file.php it should be deleted from the public_html how? Link to comment https://forums.phpfreaks.com/topic/270839-unlink-a-php-file-right-after-accessing-it/ Share on other sites More sharing options...
Andy123 Posted November 17, 2012 Share Posted November 17, 2012 Take a look at this solution, which uses PHP's unlink function. I wasn't sure if you could use unlink in a script that is currently executing, but it appears that you can. Link to comment https://forums.phpfreaks.com/topic/270839-unlink-a-php-file-right-after-accessing-it/#findComment-1393277 Share on other sites More sharing options...
lovephp Posted November 17, 2012 Author Share Posted November 17, 2012 which answer? Link to comment https://forums.phpfreaks.com/topic/270839-unlink-a-php-file-right-after-accessing-it/#findComment-1393278 Share on other sites More sharing options...
Andy123 Posted November 17, 2012 Share Posted November 17, 2012 The first one as I initially wrote in my post. I have edited the link to go straight to the answer. Link to comment https://forums.phpfreaks.com/topic/270839-unlink-a-php-file-right-after-accessing-it/#findComment-1393281 Share on other sites More sharing options...
lovephp Posted November 17, 2012 Author Share Posted November 17, 2012 by just adding this line unlink(__FILE__); would do the job or i need to do it like unlink(file.php); Link to comment https://forums.phpfreaks.com/topic/270839-unlink-a-php-file-right-after-accessing-it/#findComment-1393282 Share on other sites More sharing options...
AyKay47 Posted November 17, 2012 Share Posted November 17, 2012 Using __FILE__ will allow you to delete files dynamically. unlink("somefile.php") will be static. May I ask why you are wanting to do this in the first place? Link to comment https://forums.phpfreaks.com/topic/270839-unlink-a-php-file-right-after-accessing-it/#findComment-1393283 Share on other sites More sharing options...
lovephp Posted November 17, 2012 Author Share Posted November 17, 2012 yes i have some secret code in the file.php which i would want to be gone for good when i access the file Link to comment https://forums.phpfreaks.com/topic/270839-unlink-a-php-file-right-after-accessing-it/#findComment-1393284 Share on other sites More sharing options...
lovephp Posted November 17, 2012 Author Share Posted November 17, 2012 thanks works great Link to comment https://forums.phpfreaks.com/topic/270839-unlink-a-php-file-right-after-accessing-it/#findComment-1393285 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.