现在的位置: 首页 > 综合 > 正文

asp.net FileUpload 判断上传文件是否为图片

2013年10月16日 ⁄ 综合 ⁄ 共 280字 ⁄ 字号 评论关闭

                if (!FileUpload1.HasFile)
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请选择上传图片!');", true);
                    return;
                }
                if (FileUpload1.PostedFile.ContentType.ToLower().IndexOf("image/") == -1)
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请上传图片!');", true);
                    return;
                }

抱歉!评论已关闭.