get image height and width in file tag javascript [duplicate]
Possible Duplicates:
Determining image file size + dimensions via Javascript? How to upload preview image before upload through JavaScript get image height and width in file tag using javascript
how can i get the height and width of image without page refresh in file tag?
<HTML>
<HEAD>
<TITLE></TITLE>
<script language="javascript">
function getW()
开发者_JAVA技巧{
var theImg = document.getElementById('testimg');
alert(theImg.width);
}
function getH()
{
var theImg = document.getElementById('testimg');
alert(theImg.height);
}
</script>
</HEAD>
<BODY>
<input type="file" id="testimg"/>
<input type="button" value="get Width" onclick="getW()"/>
<input type="button" value="get Height" onclick="getH()"/>
</BODY>
</HTML>
i get the image height and width of image using php code, but that time page will be refreshed, without page refresh i get image size but not a height and width....
JavaScript cannot access the file system of the browser's computer. It has no way to read the width and height of that file.
Please read this
Should setting an image src to data URL be available immediately?
How to upload preview image before upload through JavaScript
精彩评论