2011-10-20 46 views
0

我不明白MVC3和Uploadify背後發生的事情的細節。我需要允許下面的頁面上傳多個文件。這工作到目前爲止。我可以上傳文件,他們會保存到服務器。問題是我需要使用上傳文件列表的摘要重新加載頁面。這將像在asp.net webforms中的回傳。如何獲取控制器在uploadify後執行操作?

@model Tangible.Models.UploadViewModel 

     <input id="uploadfile" name="uploadfile" type="file" class="uploadify" /> 

The template provided outlines the upload headings and format for Disposed Assets, Leased, Loaned, Rented, and Business Assets. 

The files must be uploaded in Microsoft Excel format following the templates provided. Each template must be a separate worksheet within the Excel file being uploaded. Prior to uploading, please review the template in Excel format which requires all headings be located in row one. Do not use commas in numeric fields but the decimal place character 「.」 is required when indicating cents. If you have any questions or concerns regarding the format please contact our Tangible Personal Property Department at 941.861.8291. 

Note: Summary schedule item 21.- Pollution Control Equipment must be accompanied by the current DEP certificate for the reported equipment. (Please include an upload for a DEP Certificate) 



     <script type="text/javascript"> 
      $(document).ready(
      function() { 
      @{ var auth = Request.Cookies[FormsAuthentication.FormsCookieName] == null ? string.Empty : Request.Cookies[FormsAuthentication.FormsCookieName].Value;} 
       var auth = "@auth"; 
       var ASPSESSID = "@Session.SessionID";     

       $(".uploadify").uploadify({ 
        'uploader': '@Url.Content("~/Scripts/uploadify.swf")', 
        'cancelImg': '@Url.Content("~/Images/cancel.png")', 
        'buttonText': 'Upload', 
        'script': '@Url.Content("~/Wizard/Upload")', 
        'fileDesc': 'Files', 
        'fileExt': '*.*', 
        'auto': true, 
        'scriptData': { ASPSESSID: ASPSESSID, AUTHID: auth} 
       }); 
      } 
     ); 

      </script> 

- 控制器動作:需要以某種方式做最後的步驟之後,所有文件都上傳到回傳

[HttpPost] 
     public ActionResult Upload(HttpPostedFileBase FileData) 
     { 
      var saveLocation = Path.Combine(Server.MapPath("\\"), "returns\\" + DR405Profile.CurrentUser.TangiblePropertyId); 
      System.IO.Directory.CreateDirectory(saveLocation); 
      FileData.SaveAs(Path.Combine(saveLocation, FileData.FileName)); 
      ViewData["UploadStatus"] = String.Format("File name: {0}, {1}Kb Uploaded Successfully.", FileData.FileName, (int)FileData.ContentLength/1024); 
      return View(); 
     } 

回答

1

您可以訂閱的客戶端上的onAllComplete事件,做任何你想做的事那裏。例如,您可以重新加載當前的url,發送一個AJAX請求以僅刷新url的一部分,...探索documentation,您可能會發現訂閱的有趣選項和事件。

相關問題