在文件标签javascript中获取图像的高度和宽度 [英] get image height and width in file tag javascript

查看:50
本文介绍了在文件标签javascript中获取图像的高度和宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复项:
通过Javascript确定图像文件的大小和尺寸?
如何在通过JavaScript上传之前上传预览图像
使用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>

我使用php代码获得图像的图像高度和宽度,但是该时间页面将被刷新,而无需页面刷新,我得到图像的大小但高度和宽度却没有....

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无法访问浏览器计算机的文件系统.它无法读取该文件的宽度和高度.

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

这篇关于在文件标签javascript中获取图像的高度和宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆