Hello I have the following code that gets a file, an image, from an input and posts it to php it all works great but I want to find the height and width of the image first. How do I do this? Here is my code:
 $(':file').change(function(){
  file = this.files[0];  
});
function doit(){
    var formData = new FormData($('form')[0]);
    //console.log(dataObj);
    if(file.name.length < 1) {
        TooBig = true
    }
    else if(file.size > 1000000) {
        TooBig = true
    }
    else if(file.type != 'image/png' && file.type != 'image/jpg' && file.type != 'image/jpeg' ) {
        TooBig = true
        console.log("done");
    }else{
        TooBig = false
    }
    if(TooBig == false){
        document.getElementById('submitbtn').innerHTML = 'Uploading';
        $.ajax({
            url: 'saveImage.php',
            type: 'POST',
            data: formData,
            processData: false,
            contentType: false,
            success: function(data){
                console.log(data);  
                nextID = data;    
                cancel2();      
            }
        });
    }else{
        document.getElementById('thumbage2').value =  "";
        document.getElementById('labelthumb2').innerHTML = ''+height;
    }
}
I tried using
file.width;
but it didn't work, can someone help me? EDIT: I want to get the height of the image while it is still in the input field.
 
    