Upload multiple files: set a Max file size for total size of the files

aleorco 23 Sep, 2019
Hi, I create a form with CF5 in which I set:
Designer Tab:
File field (enable multiple files) => multiple files can be selected with Ctrl

Setup Tab => On Submit section
Max file: this option is only to set maximum size of a single file

How can I set a check for the total size of the files?

see the image:
https://ibb.co/BcHyqQB

Thank you in advance for you help.

Alessandro
GreyHead 24 Sep, 2019
Hi Alessandro,

I've never seen that question asked before. If I recall correctly you don't know the size of a file until it has been uploaded to the server so you could check the total after form submission. I don't think that is what you want to do though??

Bob
aleorco 24 Sep, 2019
Hi GH, I assure you this is not what I want to do! 🤣 Excuse me, but I didn't explain myself completely.
When user select one or more files to upload, I need to set a validation rule to check the size because (after Submit) the form sends those files via email with PHP Mailer.
I use an email account on OVH (where my domain is hosted) to send the email to the user and if the size of the attached files to be sent is > 6/7 MB, I receive this error:
Mailer error: Could not instantiate mail function

What can I do? I've also opened a ticket to OVH asking for this error.
Thank you.

Alessandro
GreyHead 25 Sep, 2019
Hi Alessandro,

After the Upload Files action in the Submit event the file sizes should be available in the form data - use a Debugger action temporarily to see the data. You can then use Custom PHP to check the total size.

BUT I recommend that you don't send the files by email - just add links to them in the email body (you could zip them into one file if that makes it simpler for the user). Then there is no problem with the file sizes.

Bob
aleorco 25 Sep, 2019
Hi Bob, thank you for your suggestion. I think it's better to add links to the files in the email body. Now I'm trying to do this.
I think the way is to use code like this:
​$links = array();
foreach ( $form->data[files][file_upload]['link'] as $link) {
$link = "Click to download";
}
$form->data['link'] = $link;
?>

and then add {link} to the email body.

But this code do not display anything in the email body.

Can you please help me for a 2 beers and 1 coffee 😃?

Thanks!

Alessandro
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger