cañangasñangas Posted January 17, 2016 Report Share Posted January 17, 2016 Manes cortita, necesito validar las dimensiones de una imagen de un file input con js, en estos momentos lo estoy haciendo con ajax, pero me gustaría hacerlo en js puro para no tener que cargar la imagen, se que el DOM no puede acceder a el, pero ¿Hay un truquito o hack por ahí para lograrlo? Só no más, saluditos Link to comment Share on other sites More sharing options...
AshWilliams Posted January 18, 2016 Report Share Posted January 18, 2016 Podrías usar algo como esto:$('#tuFileInput').change(function() { var fr = new FileReader; fr.onload = function() { var img = new Image; img.onload = function() { alert(img.width,mg.height); }; img.src = fr.result; }; fr.readAsDataURL(this.files[0]); });Salutes Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now