Buy Now
Sign in

How to immediately delete files uploaded to the server after sending the form?

gmarra7 , May 28 2019, 11:03
G
gmarra7 81
May 28 2019, 11:03 #387082
I would like the files uploaded to the server to be deleted immediately after sending the form.

This code also works for chronoforms v6?
<?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);
}
}
?>
Thank you
healyhatman 9
May 28 2019, 12:44 #387088
foreach($this->get("upload#.[n].path") as $file)
unlink($file);
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
admin 33
May 29 2019, 09:28 #387114
If the original code posted works fine on v5 then it should work with v6, but the com_chronoforms should be changed to com_chronoforms6
Best regards
G
gmarra7 81
May 29 2019, 15:15 #387134
 1
 Answer
Yes in fact I have adapted it and it works perfectly.
Thank you
G
gmarra7 81
May 29 2019, 15:17 #387135
Yes latest version of Chronoforms for Wordpress