2013-02-24 41 views
0

我使用asp.net c#開發了一個Web應用程序。有一個FileUpload控件必須上傳人員照片。但是,當我發佈網站時,它無法正常工作!雖然在本地版本沒有看到問題。我一直在嘗試以下操作:在web.config => executionTime = 「60」FileUpload在本地運行良好,但不能很好地發佈項目

  1. 檢查的httpRuntime,另一maxRequestLength = 「4097151」
  2. 搜索網絡並沒有在出來

這裏是我的代碼:

fupImage.SaveAs(Server.MapPath(@"\UploadedImages\" + fupImage.FileName)); 
fupImage.SaveAs(Server.MapPath(@"\UploadedImages\" + fupImage.FileName)); 

這可能是什麼問題?

+0

IIS是否有訪問保存在文件夾UploadedImages文件? – 2013-02-24 10:51:00

回答

1

確保已經設置了表單enctype =「multipart/form-data」和保存的路徑確實存在,並且您有權限。您可以通過調試檢查..

下面是完整的代碼

<form id="Form1" method="post" action="/home/save" enctype="multipart/form-data"> 
    <input type="file" name="file" /> 
    <input type="submit" value="OK" /> 
</form> 

[HttpPost] 
    public ActionResult Save(HttpPostedFileBase file) 
    { 
     // Verify that the user selected a file 
     if (file != null && file.ContentLength > 0) 
     { 
      // extract only the fielname 
      var fileName = Path.GetFileName(file.FileName); 
      // store the file inside ~/App_Data/uploads folder 
      var path = Path.Combine(Server.MapPath("~/UploadedImages"), fileName); 
      file.SaveAs(path); 
     } 
     // redirect back to the index action to show the form once again 
     return RedirectToAction("Index");   
    } 
+1

問題中沒有MVC標籤 – devio 2013-02-24 11:54:07

相關問題