图片上传老是失败(C#)
大家看看这段代码有没有什么问题?图片每次上传就是失败的~~ 也没有出现任何错误提示~~希望大家可以帮帮忙
protected void upload1Button_Click(object sender, EventArgs e)
{
// proceed with uploading only if the user selected a file
if (image1FileUpload.HasFile)
{
try
{
string fileName = image1FileUpload.FileName;
string location = Server.MapPath("./ProductImages/") + fileName;
// save image to server
image1FileUpload.SaveAs(location);
// update database with new product details
ProductDetails pd = CatalogAccess.GetProductDetails(currentProductId);
CatalogAccess.UpdateProduct(currentProductId, pd.Name, pd.Description, pd.Price.ToString(), fileName, pd.Image2FileName, pd.OnDepartmentPromotion.ToString(), pd.OnCatalogPromotion.ToString());
// reload the page
Response.Redirect(Request.ApplicationPath + "/CatalogAdmin.aspx" +"?DepartmentID=" + currentDepartmentId + "&CategoryID=" + currentCategoryId +"&ProductID=" + currentProductId);
}
catch
{
statusLabel.Text = "上传图片失败";
}
}
}