Forums

How setting server validation with upload file field?

gidantrip 25 Sep, 2014
I have a problem with upload file in my form. How can I setting the validation server for my file upload file field so that it appears an alert if I upload over 10 megabyte files????

The problem is that the limit size of each files is 500 KB but if I upload a file of 10 megabyte (the limit of my server is 8 megabyte) the form it works and email arrive without attachments!!!!

Isnt it a bug????

I put this cose in no-empty field: [file_upload1], [file_upload2],[file_upload3], [file_upload4],[file_upload5], [file_upload6],[file_upload7], [file_upload8],[file_upload9], [file_upload10],[file_upload11], [file_upload12],[file_upload13], [file_upload14]: error message

but with this code even with 50 KB files size it apperas the error message!!!!!
GreyHead 26 Sep, 2014
Hi gidantrip,

ChronoForms doesn't k now anything about the file until after it has been uploaded by PHP. So it can't give a warning if there is no upload - except perhaps to say that no file has been found.

In the past there was no way to know the size of a file before it was uploaded - HTML 5 does, I think have the ability but it will only work in the more recent browser versions.

The simplest solution is to put a clear message in the form saying that files over 8Mb will not be uploaded.

Bob
gidantrip 28 Sep, 2014
Ok Bob
but even I put a clear message the email with file size over 8 megabyte it sended and arrived witouth attachments and with text field empty!!! The problem is that the CF5 doesnt block sending of email with file size over server size limit upload file!!!
GreyHead 28 Sep, 2014
Hi gidantrip,

As I said, ChronoForms doesn't know that the file has been blocked by the server settings :-(

Is the upload required?

Bob
gidantrip 28 Sep, 2014
but Cannot I use some server validation o custom validation????
GreyHead 29 Sep, 2014
Hi gidantrip,

If you make it required then possibly you can. if it isn't required I'm not sure that you can tell the difference between 'no file uploaded' and 'file uploaded but failed'.

I suggest that you try printing out the $_FILES array in each case to see if you can tell the difference.
<?php
echo'<div>$_FILES: '.print_r($_FILES, true).'</div>';
?>

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