Forums

Delete upload after the email

mdekleine 19 Jan, 2010
Hi,

I like to delete all uploads after the mail has been sent. Don't need them anymore and I don't have the webspace to keep all those uploads.

Obvious choice is to use the "On Submit code - after sending email:" code block, but the problem is that you really don't know which files to delete. If 2 persons are submitting a form at the same time, I might be deleting uploads which were not sent yet.

While looking for an fix, I opened the chronoformuploads.php file in the library map and found the nice looking function deleteUploads().
<? CFUploads::deleteUploads(); ?>

But putting that in the code block mentioned above didn't work...

Any suggestions how to do this?
nml375 19 Jan, 2010
Hi,
Try something along these lines:
<?
$MyForm =& CFChronoForm::getInstance('formname');
$MyUploads =& CFUploads::getInstance($MyForm->formrow->id);
$MyUploads->deleteUploads();
?>

Just remember to change 'formname' to whatever you named your form.

/Fredrik
mdekleine 22 Jan, 2010
Thanks a lot! this works like a charm.

Only when using it on a form with 8 uploads, I got the following error on the 'after submit and sending email' page:

JFTP::delete: Bad response
JFTP::delete: Bad response
JFTP::delete: Bad response

All uploads were attached to the email and all uploads were deleted from the file system. So I guess the delete function works. How can I surpress these error messages?
GreyHead 23 Jan, 2010
Hi mdekleine,

ChronoForms is using the core Joomla file delete method there so it's not a ChronoForms message. Try turning off the FTP options in your Site Global Configuration.

Bob
mdekleine 24 Jan, 2010
Well, I have to use the FTP option as the hosting party has safemode turn ON ... and they are not willing to turn it off. Perhaps surpressing all error messages will me get rid of it. Thanks for the answer.
This topic is locked and no more replies can be posted.