我在上传功能中遇到了获取图像的宽度
和高度
的问题。
这是我目前的代码:
// internal function that creates an input element
var file=newElement("input",0,"");
// sets the input element as type file
file.type="file";
file.multiple="multiple";
file.name="photoupload[]";
file.accept="image/*";
file.onchange=function(e){
// internal function that creates an image element
var img=newElement("img",0,"");
img.src=URL.createObjectURL(this);
img.onload=function(){
var cw=img.clientWidth;
var ch=img.clientHeight;
alert(cw);alert(ch);
}
}
file.click();
不太确定该如何解决这个问题。需要帮助,谢谢。