Buy Now
Sign in

Unexpected < when trying to delete old files uploaded

Dtorr1981 , May 28 at 11:21
D
Dtorr1981
Hi Guys,
I'm using CFv6 and have added a custom code action to delete older files uploaded through the form, both for data security and also to ensure the folder size does not get too big.
I found the following code snippet here and added it in to a custom PHP form action but I am receiving an error 'syntax error, unexpected '<', expecting end of file'
<?php
// change the next line to match your upload folder
// Use this version for Joomla! 2.5 or earlier
//$files = glob(JPATH_SITE.DS.'components'.DS.'com_chronoforms'.DS.'uploads'.DS.'*');
// use this version for Joomla! 3 or later
$files = glob(JPATH_SITE.'/components/com_chronoforms/uploads/*');
// set 'keep' period to 7 days
$checktime = time() - 7 * 24 * 60 * 60;
foreach ( $files as $v ) {
if ( is_file($v) && filemtime($v) < $checktime ) {
unlink($v);
}
}
?>
Does anyone have any idea's, does this code not work with CFv6?
Regards
Donna
Founder/Web Developer at Site Wide Design
D
DrSmith69
Hi Donna,
If you are using a php specific field you must remove the php tags:
<?php and ?>
else use a custom code field with the tags itself