对于IE就用FileSystemObject,
对于mozilla,netscape以及Mozilla based browser,惭愧.......

解决方案 »

  1.   

    有安全提示的.<HTML><HEAD> 
    <SCRIPT> function getFileSize (fileName) { if (document.all) { 
    window.oldOnError = window.onerror;     
    window.onerror = function (err) { 
    if (err.indexOf('utomation') != -1) { 
    alert('没有访问文件的权限');         
    return true;       
    }      
    else 
    return false;     
    }; 
        var fso = new ActiveXObject('Scripting.FileSystemObject'); 
        var file = fso.GetFile(fileName);     
    window.onerror = window.oldOnError; 
        return file.Size;  }} 
    </SCRIPT> 
    </HEAD> 
    <BODY> 
    <FORM NAME="formName"><INPUT TYPE="file" NAME="fileName"><BR> 
    <INPUT TYPE="button" VALUE="查看文件字节大小" ONCLICK="alert(getFileSize(this.form.fileName.value)+'字节')"><BR> 
    </FORM></BODY> 
    </HTML>
      

  2.   

    <SCRIPT language=javascript>
    function index_image_valid(){
    var img=new Image();
    img.src=document.pho_up.pho_index.value;
    imagewidth=img.width;
    imageheigth=img.height;
    fsize=img.fileSize/1024;
    fsize=fsize.toFixed(1);
    document.pho_up.cmd.disabled=true;
    if(img.readyState!="complete")
      window.setTimeout("index_image_valid()",10);
    else
      {alert ("宽:"+imagewidth+"\n高:"+imageheigth+"\n大小:"+fsize+" KB");
       document.pho_up.cmd.disabled=false}
    }
    </script>
    </head>
    <form name="pho_up" method="post" enctype="multipart/form-data">
    <input type="file" name="pho_index" size="20">
    <input type=button name="cmd" value="测试图片大小" onclick="index_image_valid();"> 
    </form>
      

  3.   

    我用wanghr100(灰豆宝宝.net) 的方法试验,运行时提示错误:错误:Automation服务器不能创建对象请各位赐教如何解决。
    多谢!!!