I have a code that checks the size before sending the file, I would like to know how to check the file extension along, for example, I need these extensions .jpg, png, .gif, .pdf, .txt, .doc, .docx
. Would I have to do in the same code? How would I do that?
Code
$j(function () {
$j("#arquivo").change(function () {//ou Id do input
var fileInput = $j(this);
var maxSize = $j(this).data('max-size');
console.log(fileInput.get(0).files[0].size);
//aqui a sua função normal
if (fileInput.get(0).files.length) {
var fileSize = fileInput.get(0).files[0].size; // in bytes
if (fileSize > maxSize) {
$j('#resultado').text('Arquivo excedeu o limite permitido, por favor escolha arquivos com no maximo 2GB*');
$j('#validate').attr('disabled', 'disabled');
} else {
$j('#validate').removeAttr('disabled');
$j('#resultado').hide();
}
}
});
});