I'm using ChronoForms 3.2 and Joomla 1.5.26. I see the folder Uploads is growing too much. Can I set the component to delete those files automatically? Or must I delete them manually? Thanks.
Forums
Delete upload files
Hi FAMMA,
From an older forum post I found a code example which I've updated here to include a 'keep period' so that only older files are deleted:
You could include this as a Custom Code action in your form in which case the housekeeping will be done each time the form submits. Or you could set it up as a scheduled cron job on the server to run every few days.
Bob
From an older forum post I found a code example which I've updated here to include a 'keep period' so that only older files are deleted:
<?php
// change the next line to match your upload folder
$files = glob(JPATH_SITE.DS.'components'.DS.'com_chronoforms'.DS.'uploads'.DS.'*');
// set 'keep' period to 7 days
$checktime = time() - 7 * 24 * 60 * 60;
foreach ( $files as $v ) {
if ( is_file($v) && filetime($v) < $checktime ) {
unlink($v);
}
}
?>
NB Not tested and may need debugging !!You could include this as a Custom Code action in your form in which case the housekeeping will be done each time the form submits. Or you could set it up as a scheduled cron job on the server to run every few days.
Bob
Thank you very much, I'll test the code. If do I want keep the files 30 days I can change "$checktime = time() - 7 * 24 * 60 * 60;" by "$checktime = time() - 30 * 24 * 60 * 60;"?
This topic is locked and no more replies can be posted.