validate image input file multiple jquery in 4 ways

0

Good evening guys, I have an input file multiple and I need to do 4 validations before sending the form.

1) Limit the number of images sent in 10

2) Images have to be of type jpeg or png (just put an accept in the html already solves this completely?)

3) Each image n can be greater than 2mb

4) Minimum image width should be 600px

Can you give me strength? I was doing all this validation after sending the file to the server, but it is bad to send everything to later test.

    
asked by anonymous 30.07.2016 / 01:05

1 answer

0

Hello

1) You can find your solution here

2) You can search more on Google by searching how to validate file extensions. Here's another solution

3) Workaround here

4) In JavaScript:

var largura = document.getElementById("imagem").width; // retorna a largura
    var altura = document.getElementById("imagem").height; // retorna a altura

In Jquery

var largura = $('#imagem').width(); // retorna a largura
var altura = $('#imagem').height(); // retorna a altura

Now it's up to you, just create the necessary functions before sending it to the server.

    
30.07.2016 / 04:58