我有一个产品表,其中包含制造商、产品类别等列;像这样:
manufacture name = stem ware
category name = simon pearce
product name = white flute ..
对于这个产品,它已经有一个图像现在我正在向这个产品上传一个新图像,但问题是上传的新图像没有保存在服务器上。
我相信我的代码是正确的,因为它只发生在这个特定的产品上,而不是其他产品上,有人知道为什么会这样吗?
这是我的代码:
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
int fileSize1 = FileUpload1.PostedFile.ContentLength;
string filename1 = FileUpload1.FileName;
//Checking the pic 1 Format
if (CheckImageFormat(filename1.ToUpper()) == true)
{
}//Pic 1 Ends
item1 = txtitemNo.Text.Replace("/", "-");
manufacturer1 = ddlMake_all.SelectedItem.Text;
string subPath = "~/images/Products/" + manufacturer1;
bool IsExists = System.IO.Directory.Exists(Server.MapPath(subPath));
if (!IsExists)
{
System.IO.Directory.CreateDirectory(Server.MapPath(subPath));
}
path1 = "~/images/Products/" + manufacturer1 + "/" + item1 + ".jpg";
string fileExt = System.IO.Path.GetExtension(FileUpload1.FileName);
if (fileExt == ".jpeg" || fileExt == ".jpg" || fileExt == ".gif" || fileExt== ".png" || fileExt == ".JPEG" || fileExt == ".JPG" || fileExt == ".GIF")
{
FileUpload1.SaveAs(Server.MapPath(path1));
}
else
{
lblnewmsg.Text = "Please upload Correct image";
}
}
}