如何判断上传图片的大小,要求小于20k!!!!急 试过了var image=new Image(); image.dynsrc=pluginFUpLoad; alert(image.fileSize); 但是不行,不支持dynsrc属性,也不是浏览器设置的问题,还有其他方法吗 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 那样alert(image.fileSize); 结果是-1 等图片加载完后才alertvar image=new Image(); image.onload = function(){ alert(image.fileSize);} image.src="1.bmp"; 我是file选取,然后点击form中的确定提交表单时在js前台进行验证这个上传的图片大小符不符合要求不加载。。可有解决办法 请把提交表单的代码写在onload的回调函数里面var image=new Image();image.onload = function(){ var imageSize = image.fileSize / 1024; if (imageSize > 20){ alert("图片超出20k"); } else { //提交表单 }}image.src="1.bmp"; 在服务器端判断也行啊File file = new File("图片路径");long size = file.length();if(size > 20*1024){} 通过Flash ,如果你自已不会写,,网上到处都是... AS可以实现,通过FileReference可以获取到文件的大小。 AS可以实现,FileReference可以获取文件的大小。 如何实现点击超链接后变色! 按钮背景色循环改变 js问题 求修正setcachebreakers的代码,技术有限,不知道哪里出错 在html 給.js文件傳值 window.print()方法如何打印有"横向滚动条的div" 下拉框的问题 简单问题:请问如何保留两位小数。 可以在桢里调用另外一桢里的js函数么? window.document.body.innerHTML报错:Cannot read property 'body' of undefined 以下js浮动提示层可以点击关闭,如何增加一个链接可以点击再打开这个层? 选项卡没有效果谁帮我看看啊 谢谢了
var image=new Image();
image.onload = function(){
alert(image.fileSize);
}
image.src="1.bmp";
var image=new Image();
image.onload = function(){
var imageSize = image.fileSize / 1024;
if (imageSize > 20){
alert("图片超出20k");
} else {
//提交表单
}
}
image.src="1.bmp";
long size = file.length();
if(size > 20*1024)
{
}