<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script language="JavaScript">
<!--
function filesize(filename)
{
var fso, f, s;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFile(filename);
alert(f.Size);
}
//-->
</script>
</head><body><input type=file onpropertychange="filesize(this.value)" name="file">
</body>
</html>
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script language="JavaScript">
<!--
function filesize(filename)
{
var fso, f, s;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFile(filename);
alert(f.Size);
}
//-->
</script>
</head><body><input type=file onpropertychange="filesize(this.value)" name="file">
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script language="JavaScript">
function filesize(filename)
{
var fso, f, s;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFile(filename);
alert(f.Size);
}
</script>
</HEAD>
<body>
<input type="file" onpropertychange="filesize(this.value)" name="file">
</body>
</HTML>
var img=null;
function s()
{
if(img)img.removeNode(true);
img=document.createElement("img");
img.style.position="absolute";
img.style.visibility="hidden";
img.attachEvent("onreadystatechange",orsc);
img.attachEvent("onerror",oe);
document.body.insertAdjacentElement("beforeend",img);
img.src=inp.value;
}
function oe()
{
alert("cant load img");
}
function orsc()
{
if(img.readyState!="complete")return false;
alert("图片大小:"+img.offsetWidth+"X"+img.offsetHeight);
alert("图片尺寸:"+img.fileSize);
btn.disabled=false;
}
</script>
<input id=inp type="file">
<br>
<button onclick="s()">Test</button><button id=btn disabled>UpLoad</button>
别人写的!我转载
为ActiveX设置IObjSafe接口
=====================================
function __GetFileSizeFso(strPath){
try{
var oFso=new ActiveXObject("Scripting.FileSystemObject");
}catch(e){
return -1;
}
try{
var oFile=oFso.GetFile(strPath);
}catch(e){return -1;}
var m_Fs=oFile.Size;
oFile=null;
oFso=null;
return m_Fs;
}
function __GetFileSizeOcx(strPath){
try{
var oOcx=new ActiveXObject("WebTools.FileSystem");
}catch(e){
return -1;
}
var m_Fs=oOcx.FileSize(strPath);
oOcx=null;
return m_Fs;
}