Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 我已将图像上载到服务器,但它未保存在服务器中_Asp.net_File Upload - Fatal编程技术网

Asp.net 我已将图像上载到服务器,但它未保存在服务器中

Asp.net 我已将图像上载到服务器,但它未保存在服务器中,asp.net,file-upload,Asp.net,File Upload,我有一个product表,其中有Manufacturer、category product等列。;像这样: manufacture name = stem ware category name = simon pearce product name = white flute .. 对于这个产品,它已经有一个图像,现在我正在上传一个新图像到这个产品,但问题是上传的新图像没有保存在服务器上 我相信我的代码是正确的,因为它只发生在这个特定的产品上,而不是其他产品上,有人知道为什么会发生这种情况吗

我有一个product表,其中有Manufacturer、category product等列。;像这样:

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";
        }
    }
}

您是否在
FileUpload1.SaveAs(Server.MapPath(path1))上设置了断点
查看Server.MapPath(path1)解析为什么?而不是使用~/user path1=“images/Products/”+manufacturer1+“/”+item1+”.jpg”;