Dudditz Posted March 5, 2008 Share Posted March 5, 2008 Noob question: I was wondering if its possible for a php file to delete itself? I often upload temporary files for others to view which I do not want to remain in my webspace but for a short time. If there is no script to delete itself, does anyone know of a snippet or something to delete based on a time() variable inside the targeted file? Example: the_deleter.php scans the first line of each file in a directory where a time() variable is placed. It then checks that variable against a deletion time and determines either to delete the file or pass to the next file. Thanks Link to comment https://forums.phpfreaks.com/topic/94398-time-based-delete/ Share on other sites More sharing options...
drisate Posted March 5, 2008 Share Posted March 5, 2008 use cron to auto delete based on time Link to comment https://forums.phpfreaks.com/topic/94398-time-based-delete/#findComment-483478 Share on other sites More sharing options...
Dudditz Posted March 5, 2008 Author Share Posted March 5, 2008 use cron to auto delete based on time I would but wanted each file with a different deletion time. file one - delete time 3AM file two - delete time 1PM file three - delete time - Dec 31,2010 I am attempting to write something using the unlink() currently but the time function is really messing me up. Just thought there may be an easier approach. Thanks. Link to comment https://forums.phpfreaks.com/topic/94398-time-based-delete/#findComment-483490 Share on other sites More sharing options...
drisate Posted March 5, 2008 Share Posted March 5, 2008 make up 3 crons pointing at a cron.php file then check the time and delete the file if (date("H")=="3"){ //it's 3 am delete the shit @unlink($path1); }elseif (date("H")=="13"){ //it's 1 pm delete the shit @unlink($path2); }elseif [...] Link to comment https://forums.phpfreaks.com/topic/94398-time-based-delete/#findComment-483497 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.