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

Recommended Answers

All 4 Replies

Member Avatar for LastMitch

@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.

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);
}
<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;

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.