首页 > 代码库 > wenform控件fileupload上传文件

wenform控件fileupload上传文件

string url;
if (this.FileUpload1.HasFile)
{
string savePath = Server.MapPath("images/banner/");
string fileName = this.FileUpload1.FileName;
string extension = Path.GetExtension(fileName);
if (extension != ".jpg" && extension != ".png" && extension != ".gif")
{
Response.Write("<script>alert(‘图片格式必须为.jpg、.png或.gif格式!‘);</script>");
return;
}
this.FileUpload1.SaveAs(savePath + "/" + fileName);
url = fileName;
}

wenform控件fileupload上传文件