2

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()

{

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

Community
  • 1
  • 1
keyur
  • 483
  • 1
  • 6
  • 14
  • Same question?? -> http://stackoverflow.com/questions/6633190/get-image-height-and-width-in-file-tag-javascript – Pwnna Jul 09 '11 at 06:37

2 Answers2

1

JavaScript cannot access the file system of the browser's computer. It has no way to read the width and height of that file.

Dan Grossman
  • 49,405
  • 10
  • 105
  • 95
  • I thought it could with HTML5. I remember seeing thing such as a MP3 player with JS + HTML – Pwnna Jul 09 '11 at 06:40
0

Please read this

Should setting an image src to data URL be available immediately?

How to upload preview image before upload through JavaScript

Community
  • 1
  • 1
mplungjan
  • 134,906
  • 25
  • 152
  • 209