开发者

get image height and width in file tag javascript [duplicate]

This question already has answers here: Closed 11 years ago.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜