Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The solution:</p> <p>The viewmodel:</p> <pre><code>public class CustomerDocUploadViewModel { public HttpPostedFileBase File { get; set; } public int FromLanguage { get; set; } public int ToLanguage { get; set; } } </code></pre> <p>The view:</p> <pre><code>@model IList&lt;Models.ViewModels.CustomerDocUploadViewModel&gt; </code></pre> <p>...</p> <pre><code>&lt;form action="UploadDoc" method="post" enctype="multipart/form-data"&gt; &lt;table id="tblUploadDocs"&gt; &lt;tr id="row1"&gt; &lt;td&gt;&lt;input type="file" name="[0].File" /&gt;&lt;/td&gt; &lt;td&gt;Bu dilden&lt;/td&gt; &lt;td&gt;@Html.DropDownList("[0].FromLanguage", ViewBag.Languages as SelectList)&lt;/td&gt; &lt;td&gt;şu dile çevrilecek&lt;/td&gt; &lt;td&gt;@Html.DropDownList("[0].ToLanguage", ViewBag.Languages as SelectList)&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;br /&gt; &lt;a id="lnkAdd" href="javascript:addRow();" style="margin:10px 0;"&gt;Yeni dosya ekleyin&lt;/a&gt; &lt;input type="submit" /&gt; &lt;/form&gt; </code></pre> <p>and finally the action method in the controller:</p> <pre><code>[HttpPost] public ActionResult UploadDoc(IList&lt;CustomerDocUploadViewModel&gt; docInfos) { for (int i = 0; i &lt; docInfos.Count; i++) { if (docInfos.ElementAt(i).File != null &amp;&amp; docInfos.ElementAt(i).File.ContentLength &gt; 0) { byte[] data = new byte[docInfos.ElementAt(i).File.ContentLength]; docInfos.ElementAt(i).File.InputStream.Read(data, 0, docInfos.ElementAt(i).File.ContentLength); // Save the file into the database Document doc = new Document { UploadedOn = DateTime.Now, MimeType = docInfos.ElementAt(i).File.ContentType, UserName = User.Identity.Name, Data = data, FromLanguage = docInfos.ElementAt(i).FromLanguage, ToLanguage = docInfos.ElementAt(i).ToLanguage }; dbContext = new MedicalDb(); dbContext.Documents.Add(doc); dbContext.SaveChanges(); } } return RedirectToAction("Index"); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload