[java]代码库
<input type="file" id="fileText">
<input type="button" value="getSize" onclick="checkFileChange(document.getElementById('fileText'));">
<script type="text/javascript">
var Sys = {};
if(navigator.userAgent.indexOf("MSIE")>0)
{
Sys.ie=true;
}
if(isFirefox=navigator.userAgent.indexOf("Firefox")>0)
{
Sys.firefox=true;
}
function checkFileChange(obj)
{
var filesize = 0;
if(Sys.firefox)
{
filesize = obj.files[0].fileSize;
}else if(Sys.ie)
{
var fileobject = new ActiveXObject ("Scripting.FileSystemObject");
var file = fileobject.GetFile (document.getElementById("fileText").value);
var filesize = file.Size;
}
alert(filesize);
}
</script> //源代码片段来自云代码http://yuncode.net