0

hai every one.. am uploading image file before uploading i want know the height and width of image and also size of file please help in java script. thank you

3
Contributors
4
Replies
14
Views
4 Years
Discussion Span
Last Post by chandub
0

@chandub

hai every one.. am uploading image file before uploading i want know the height and width of image and also size of file please help in java script. thank you

what have you done so far? Can you post the code you are working so give a better idea how approach it.

Edited by LastMitch: grammer

0

you can take following function for getting size of image.

function getImgSize(imgSrc)
{
var newImg = new Image();
newImg.src = imgSrc;
var height = newImg.height;
var width = newImg.width;
alert ('The image size is '+width+'*'+height);
}
0
<tr>       
     <td><input type="file" name="imageFile" id="imageFile" accept="jpg,gif,png" />
    </td>            
<tr>

am trying to get image height and width by using following code but it's not working. and I get confused by some documents they are say like some property of local system files are available to access from java script like size but am unable to get those properties

var imgObj = document.getElementById('imageFile');
var newImg = new Image();
newImg.src = imgObj.attr('src');
var height = newImg.height;
var width = newImg.width;

Edited by chandub

0

thank you sir.. I did like this i stored image in temp folder in server and through that i get an width and height of image before storing it into database

thak you for all

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.