JS代码如下:
1 function getFileSize(filePath){ 2 var image=new Image(); 3 image.dynsrc=filePath; 4 alert(image.fileSize); 5 }
上面是图片的大小
IE7下不支持属性dynsrc,可以用src代替
也可以获取图片的长度与宽度
1 function PreviewImg(imgFile){2 var image=new Image();3 image.src=imgFile.value;4 imgDiv.style.width = image.width;5 imgDiv.style.height = image.height;6 }
调试:
在IE6中运行正常,不过在IE7,IE8中还是有问题,还未找到解决方案
转自http://jiachen.blogbus.com/logs/34148035.html
|