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

Delete uploaded files immediately after form submission.

Overview

The issue is that uploaded files remain on the server after a form is sent.
Use a custom action in your CF form to delete the files by their stored paths after processing. Ensure the component path in the code matches your CF version.

Answered
ChronoForms v6
gm gmarra7 28 May, 2019
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
he healyhatman 28 May, 2019
foreach($this->get("upload#.[n].path") as $file)
unlink($file);
Max_admin Max_admin 29 May, 2019
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
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
gm gmarra7 29 May, 2019
Answer
1 Likes
Yes in fact I have adapted it and it works perfectly.

Thank you
gm gmarra7 29 May, 2019
Yes latest version of Chronoforms for Wordpress
This topic is locked and no more replies can be posted.