朋友我需要你的帮助来解决问题。
DETAIL 我有一个基于更新面板的注册表单(在幻灯片中工作),其中一张幻灯片要求用户上传他/她的照片(可选)。
问题 一切正常,精美的名字保存在数据库中,用户文件夹在服务器端创建但是文件没有上传......没有错误。
CODES
@primePhoto - FileUpload1
protected void RegisterClick6(object sender, EventArgs e)
{
string pathToCreate = "img/users/" + userName.Text;
if (Directory.Exists(Server.MapPath(pathToCreate)))
{
}
else
{
Directory.CreateDirectory(Server.MapPath(pathToCreate));
}
String imageFolder = pathToCreate;
String savePath;
String saveFile;
if (FileUpload1.HasFile)
{
savePath = Path.Combine(Request.PhysicalApplicationPath, imageFolder);
saveFile = Path.Combine(savePath, FileUpload1.FileName);
FileUpload1.SaveAs(saveFile);
}
SqlConnection con = new SqlConnection(str1);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "RegisterUser";
cmd.Parameters.AddWithValue("@userName", userName.Text);
cmd.Parameters.AddWithValue("@email", Email.Text);
cmd.Parameters.AddWithValue("@postDate", currentDate.Text);
cmd.Parameters.AddWithValue("@password", Password.Text);
cmd.Parameters.AddWithValue("@FirstName", FirstName.Text);
cmd.Parameters.AddWithValue("@LastName", LastName.Text);
cmd.Parameters.AddWithValue("@primePhoto", FileUpload1.FileName);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
multiview1.SetActiveView(view7);
}
答案 0 :(得分:0)
添加触发器以更新面板,如:
<Triggers>
<asp:PostBackTrigger ControlID="RegisterClick6" />
</Triggers>