1

zip ファイルをアップロードし、ボタンをクリックして同じフォルダーに解凍し、このフォルダーに同じ名前を付ける必要があります。どこから始めればよいかわかりません。アップロードの部分があります: 私の見解:

  <% using (Html.BeginForm(null, null, FormMethod.Post, new { enctype = "multipart/form-data" }))
   { %>                                       

       <%: Html.ZincValidationSummary() %>  
       <%: Html.ZincValidationErrors() %>           

       <div class="section _100">
         <%: Html.LabelFor(model => model.Name)%>                               
         <div>
           <%: Html.TextBoxFor(model => model.Name, new { maxlength = "100" })%>     
           <%: Html.ValidationMessageFor(model => model.Name)%> 
         </div>
       </div>   

       <div class="section _100">           
         <%: Html.LabelFor(model => model.ScormPackageFile) %>
         <div>
           <br />
           <input type="file" id="ScormPackageFile" name="ScormPackageFile" />
           <%: Html.ValidationMessageFor(model => model.ScormPackageFile)%>
           <br />
         </div>
       </div>
       <div class="actions">
         <div class="actions-right">
           <input type="submit" value="<%: Html.Resource(Resources.Global.Button.Save) %>" class="submit_button" />
         </div>
       </div>  
  <% } %>

コントローラーで:これは私が何をすべきか分からないところです:

 HttpPost]
 public ActionResult Upload(ScormUploadViewModel model)
 {
  if (ModelState.IsValid)
  {
    if (model.ScormPackageFile != null)
    {
      string extractDir = "c:\\TSFPreview\\Zinc\\Web\\Project\\ScormPackages";
      //I should get the above dir from the uploaded file's directory because the                   
        unziped folder will be in the same folder 


    }
    var smallImageUrl = MediaStorageService.UploadFromStream(Zinc.Media.MediaType.Attribute, model.ScormPackageFile.FileName, model.ScormPackageFile.ContentType, model.ScormPackageFile.InputStream);
      //group.SmallImageUrl = smallImageUrl;
   }
   return View(model);
 }

それから私のビューモデル:

public class ScormUploadViewModel
{
  [LocalizedRequired]
  [DataType(DataType.Text)]
  [LocalizedDisplayName(Resources.Global.Title.Name)]
  public string Name { get; set; }

  [DisplayName("Upload a scorm package")]
  public HttpPostedFileBase ScormPackageFile { get; set; }
}

おかげで、他にどのタグを追加する必要があるのか​​ わかりません。今のところ、asp.net mvc 3タグを追加しました:)

4

2 に答える 2

0

GZipStreamを見てください。これは、フレームワークに組み込まれているzipサポートの1つであり、MSDNページに例があります。

于 2013-02-27T09:10:45.187 に答える
0

uzippingにいくつかのライブラリを使用できます。例:https://dotnetzip.codeplex.com/

于 2013-02-27T09:11:20.417 に答える