I want to get the width and height of an image before uploading using javascript.
I used The code shown below.
But its returning 0 value
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script>
function form_image()
{
var v=new Image();
v.src=document.getElementById("f1").getAttribute('src');
alert(v.height+"-"+v.width);
}
</script>
</head>
<body>
<form method="post" enctype="multipart/form-data">
<input type="file" id="f1" name="f1" onchange="form_image()"/>
<input type="submit" />
</form>
</body>
</html>