上传图片到指定文件目录,没有则创建目录
protected void Button1_Click(object sender, EventArgs e) { string driPath = "~/WebApplication3/" + DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/"; string phyPath = Server.MapPath(driPath); if (!Directory.Exists(phyPath)) { Directory.CreateDirectory(phyPath); } this.FileUpload1.SaveAs(phyPath+this.FileUpload1.FileName); }