2015-09-16 25 views
1

上傳圖片我想將圖像存儲到MS SQL服務器,當我將我的形象越來越目錄未找到異常的錯誤之後才提交按鈕。 在此先感謝。DirectotyNotFoundexception當我通過文件上傳工具在Asp.net

if(filuploadimages.PostedFile!=null) 
    { 
       string filename = filuploadimages.PostedFile.FileName.ToString(); 
       string fileExt = System.IO.Path.GetExtension(filuploadimages.FileName); 
       filuploadimages.SaveAs(Server.MapPath("~/Productimages/" + filename));//error 

      } 
+0

你要創建的目錄。 –

+0

怎麼樣?你能解釋清楚嗎? – Mathan

+0

手動。用該路徑創建文件夾。 –

回答

0

你從這條線得到哪條路徑?

Server.MapPath("~/Productimages/" + filename) 

我建議你嘗試讓不同的方式上傳路徑:

if (filuploadimages.PostedFile != null) 
{ 
    string filename = System.IO.Path.GetFileName(filuploadimages.PostedFile.FileName); 
    string uploadPath = System.IO.Path.Combine(Server.MapPath("~/Productimages"), filename); 
    filuploadimages.SaveAs(uploadPath); 
}