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? Quote 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()); } } ?> Quote 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. Quote 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 Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.