Verifique a largura e a altura da imagem antes de fazer o upload com Javascript
Tenho um JPS com um formulário no qual um usuário pode colocar uma imagem:
<div class="photo">
<div>Photo (max 240x240 and 100 kb):</div>
<input type="file" name="photo" id="photoInput" onchange="checkPhoto(this)"/>
</div>
Escrevi este js:
function checkPhoto(target) {
if(target.files[0].type.indexOf("image") == -1) {
document.getElementById("photoLabel").innerHTML = "File not supported";
return false;
}
if(target.files[0].size > 102400) {
document.getElementById("photoLabel").innerHTML = "Image too big (max 100kb)";
return false;
}
document.getElementById("photoLabel").innerHTML = "";
return true;
}
que funciona bem para verificar o tipo e tamanho do arquivo. Agora quero verificar a largura e a altura da imagem, mas não consig
Eu tentei comtarget.files[0].width
mas eu receboundefined
. De outras maneiras, recebo0
.
Alguma sugestão