Forums

Max file size validation not working properly

Krionis 06 Dec, 2011
Hello,
The funny thing is - when I try to upload a doc file more then 2040kB - error message shows
- when I try to upload differ file format (size about 2048kB) - error message shows
πŸ€” BUT! If I upload jpg file of 30Mb size - no error shows and e-mail with empty fields sends
πŸ™„ Thanks in advance for any help!
The settings below:

GreyHead 06 Dec, 2011
Hi Krionis,

ChronoForms can't see the file until after it is uploaded. My best guess is that 30MB is more than the Max File Upload setting in your php.ini file so the file never gets uploaded at all. ChronoForms then sees an empty Files array and assumes that there is no file upload to handle.

Bob
Krionis 07 Dec, 2011
Thanks for reply,
What about custom code event after upload event, something like this:
   function validateSize() {
        if ( $.browser.msie ) {
            var myFSO = new ActiveXObject("Scripting.FileSystemObject");
            var filepath = document.getElementById('file_attachment').value;
            var thefile = myFSO.getFile(filepath);
            var size = thefile.size;
        }else {
            var fileInput = $("#file_attachment")[0];
            var size = fileInput.files[0].size; // Size returned in bytes.
        }
        if(size > 10485060){// 10485060 = 10Mb
            alert('To big file for uploading (10Mb - max)');
            //Clean upload field
            document.getElementById('file_attachment').parentNode.innerHTML = document.getElementById('file_attachment').parentNode.innerHTML;
        }
    }   
    jQuery('#file_attachment').change(validateSize);

I tried that, but nothing happens
GreyHead 07 Dec, 2011
Hi Krionis ,

That looks like a JavaScript snippet that needs to run in the Browser - the On Submit events all run on the server and can only use PHP scripts.

Bob
Max_admin 09 Dec, 2011
Hi Krionis,

Just check your server's max file upload size setting first ? this should save everybody's time!πŸ™‚

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.