Jump to content

[js] Dimension imagen file input


Recommended Posts

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

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 :notonto:

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...