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


                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;
                }


你可能感兴趣的:(asp.net)