File upload asks for size, type...

User 2907363 Photo


Registered User
1 post

I'm trying to make sure that the file upload component validates the size and type of file before submission. Why would it ask for those limitations on the Properties tab if it isn't going to do anything with them?

How do I make it check before submission using jQuery or javascript?
Thanks!
User 187934 Photo


Senior Advisor
18,670 posts

I use this.
$('input[name="file"]').change(function(){
if(this.files[0].size > 10000000){ // 10 meg
$("#docContainer div #fileerror").html("File is too big").css('color', 'red');
$('#fb-submit-button').hide();
}else {
$('#docContainer div #fileerror').html('Valid Image Size').css('color','green');
$('#fb-submit-button').show('slow');
}
});

I then add a custom div with an id of fileerror after export below the file input.
The file type can be added to my code but I'd rather know what type of file your looking at.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

Here's my S-Drive site with
examples of what can be accomplished in VSD.
https://progrower.coffeecup.com/
Here's my CoffeeCup SCCP Shop with examples of what can be done.
https://progrower.coffeecup.com/shop/
This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.