js判断上传的图片格式

 var fileType="";

        //图片1

        var filePath=document.getElementById("FileUpload1").value;

        if(Trim(filePath)!="")

        {

      var seat=filePath.lastIndexOf(".");//注意大小写

          fileType= filePath.substring(seat).toLowerCase();   //扩展名jpg

          if(fileType!=".jpg" && fileType!=".bmp" && fileType!=".gif" && fileType!=".jpeg" && fileType!=".png")

          {

          strMessage+="图片1格式不正确,请上传jpg,gif,bmp格式的图片!\n";

          }

        }

 

posted on 2012-03-22 17:28  小景  阅读(740)  评论(0编辑  收藏  举报