关于asp.net上传图片的问题
我想把图片上传到指定文件夹,这个文件夹的名字是根据用户的名字来定,上传不成功
代码如下:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Web;
public partial class Restaurant : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label4.Text = (string)Session["resName"];//显示店的名字
Label4.Visible = true;
Label5.Text = (string)Session["resAddr"];
Label5.Visible = true;
Label12.Text = (string)Session["resType"];//显示店的类型
Label12.Visible = true;
Label8.Visible = true;
}
protected void Button2_Click(object sender, EventArgs e)
{
FileUpload1.Visible = true;
Button1.Visible = true;
}
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
if (FileUpload1.PostedFile.ContentLength < 10485760)
{
try
{
FileUpload1.PostedFile.SaveAs(System.Web.HttpContext.Current.Server.MapPath("~/店铺/'" +Label12.Text+ "'/'" +Label4.Text+ "' /")
+FileUpload1.FileName );
Image1.ImageUrl = "~/店铺/'" +Label12.Text+ "'/'" +Label4.Text+ "' /"+FileUpload1.FileName;
}
catch (Exception ex)
{