function checkFileExt()
{
 var valid=true;
 var fso = new ActiveXObject("Scripting.FileSystemObject");
 NotAllowExt=["asp","cer","cdx","asa","htw","ida","idq","shtm","shtml","stm","printer","cgi","php","php4","cfm","aspx"];
 $(".fileItem").each(function(){if(this.value!="")
   {if(NotAllowExt.find(fso.GetFile(this.value).Type)) valid=false }});
 
 return valid;
}
function checkFileSize()
{
   var uploadSize=0;
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   $(".fileItem").each(function(){if (this.value!="") uploadSize+=fso.GetFile(this.value).Size;});
   if(uploadSize>1024*1024*1024) return false;
    return true;
}
这是我写的判断上传文件文件名和大小是否合法的程序
测试第二个函数总是报错说automation服务器不能创建对象
其中用了jquery

解决方案 »

  1.   

    try
    在开始-运行regsvr32 scrrun.dll
      

  2.   

    为什么第一个函数 测试又通过了吗
    fso在客户端运行 怎么回事啊
      

  3.   

    function checkFileExt()
    {
    var valid=true;
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    NotAllowExt=["asp","cer","cdx","asa","htw","ida","idq","shtm","shtml","stm","printer","cgi","php","php4","cfm","aspx"];
    $(".fileItem").each(function(){if(this.value!="")
      {if(NotAllowExt.find(fso.GetFile(this.value).Type)) valid=false }});
    fso =null;//试一下
    return valid;