dezkit Posted August 29, 2008 Share Posted August 29, 2008 is there a way to remove a file in a directory in a week from its upload, and at the same time, remove the mysql row of it? Link to comment https://forums.phpfreaks.com/topic/121908-solved-remove-filemysql-row-in-a-week-of-its-upload/ Share on other sites More sharing options...
DarkWater Posted August 29, 2008 Share Posted August 29, 2008 Uhh, this should get you started: <?php foreach (glob('yourdirectory/*') as $filename) { if (filemtime($filename) < (time() - 86400)) { unlink($filename); $sql = "DELETE FROM uploads WHERE filename='$filename'"; mysql_query($sql) or die(mysql_error()); } } ?> Link to comment https://forums.phpfreaks.com/topic/121908-solved-remove-filemysql-row-in-a-week-of-its-upload/#findComment-629025 Share on other sites More sharing options...
FIREBALL5 Posted August 29, 2008 Share Posted August 29, 2008 PHP scripts have to be run though. It won't execute that code automatically. Link to comment https://forums.phpfreaks.com/topic/121908-solved-remove-filemysql-row-in-a-week-of-its-upload/#findComment-629032 Share on other sites More sharing options...
dezkit Posted August 29, 2008 Author Share Posted August 29, 2008 Thanks a bunch darkwater, ill try that Link to comment https://forums.phpfreaks.com/topic/121908-solved-remove-filemysql-row-in-a-week-of-its-upload/#findComment-629033 Share on other sites More sharing options...
DarkWater Posted August 29, 2008 Share Posted August 29, 2008 PHP scripts have to be run though. It won't execute that code automatically. Cron. Link to comment https://forums.phpfreaks.com/topic/121908-solved-remove-filemysql-row-in-a-week-of-its-upload/#findComment-629048 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.