<script>
alert(document.fileSize/1024+"Kb")
</script>

解决方案 »

  1.   

    我用的是AspUpload,进行文件上载,要在客户端限制其大小,这样好像不行!
      

  2.   

    刚看了一个,给你贴出来看看:<Script language="javascript">
    function mysubmit()
    {
    theform=document.form1;
        if(theform.picture.value=="")
        {
         alert("请点击浏览按钮,选择您要上传的jpg或gif文件!")
         theform.picture.focus;
         return (false);
        }
        else
        {
         str= theform.picture.value;
         strs=str.toLowerCase();
         lens=strs.length;
          extname=strs.substring(lens-4,lens);
        if(extname!=".jpg" && extname!=".gif")
        {
         alert("请选择jpg或gif文件!");
          return (false);
        }
        }
        if(img1.width>195 || img1.height>100)
        {
         alert("您上传的图片尺寸太大,这样会影响美观!请裁剪后再上传!")
         return(false);
        }
        return true;
    }
    </script>
    <form name=form1 onsubmit="return mysubmit()">
    <input type="file" name="picture" onpropertychange="img1.src=this.value;">
    <input type="submit" value="上传" name="B1" style="font-size: 12">
    </form>
    <img id="img1">
      

  3.   

    <html>
    <body bgcolor=#FFFBE7>
    <center>
    <form name="form1" action=process.asp method=post enctype="multipart/form-data" onsubmit="return check()">
    <table border=1 width=70% style="margin-top:6em" >
    <tr>
    <td colspan=2 align=center>请贴上你的相片(<20kb)</td>
    </tr> 
    <tr>
    <td>相片文件名:</td><td><input type=file name=mefile></td>
    </tr>
    <tr>
    <td align=center colspan=2><input type=submit value="发送">   <input type=reset value="取消"></td>
    </tr>
    </table>
    </form>
    </center>
    </body>
    <script>
    var fso;
    function check(){
    var errMsg,filespec=document.all.mefile.value;
    if(filespec==""){alert("请选择文件,谢谢");return false;}
    errMsg="你禁止了FSO,请刷新页面,谢谢";
    try{
    if(fso==null){
    alert("请允许启用FSO检查文件大小,谢谢");
    fso= new ActiveXObject("Scripting.FileSystemObject");
    }
    errMsg="文件过大,请重新选择,谢谢";
    if(fso.GetFile(filespec).size<20*1024)return true;
    }catch(e){}
    alert(errMsg);return false;
    }
    </script>
    </html>