ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

Unexpected < when trying to delete old files uploaded

Dtorr1981 28 May, 2018
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
DrSmith69 28 May, 2018
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
This topic is locked and no more replies can be posted.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com