UploadForm Size Check

Hello, All -

I've been experiencing a couple of issues to with the UploadForm - all of which relate to file size. If someone tries to add a large file the system will still attempt to upload it even if it is bigger than the permitted size. This can lead to problems - especially if the file is really BIG.

I want to find a way to reject a file as soon as it is selected.

The following code claims to do just that.

$(document).on("change", ".input-file[type=file]", function () {
var file = this.files[0];
alert(file.size);
if (file.size > 1024) {
alert("Too large Image. Only image smaller than 1K can be uploaded.");
$(this).replaceWith('<input class="input-file" type="file">');
return false;
}
});

I'm just not sure how to add it to the UploadForm code!

Can anyone help or suggest an alternative method.

:0/

Perch

Hey Perch,

You'll need to integrate this into the uploadform3_iframe.php, you'll need to add the code to the function submitUploadForm(), so it runs after an a file has been selected.

Thanks,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Hey Perch,

I tried to quickly integrate the code, but it's quite time consuming to add, so I'm unable to provide this as free support. 

If you set a maximum file size on upload field, the script should automatically reject any large files (See attached screenshot). 

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com
Attachments:

CMS Builder.png 93K

Hi, Greg -

I've already set-up the back-end as you describe. The point I was trying to make is that this setting has no effect on large files. It doesn't matter what size is set in the "Maximum Upload Size". (I can even leave it blank for "unlimited" file size.) If I try to upload a file above (say) 20mb, the system will always crash. The upload gets to 100% and then the page reports:

"No 'tablename' value specified in url!"

I need to fix this!

:0(

Perch

Hey Perch,

It's likely that this issue is caused by the server rejecting files of a certain size before the PHP script runs. Please can you fill out a second level support request for me:

https://www.interactivetools.com/support/email_support_form.php

If you can include the section and field that's causing the issue, then I can take a closer look at the problem.

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com