Note that there are some explanatory texts on larger screens.

plurals
  1. POUpload Image MVC always null
    text
    copied!<p>Hi everyone i am trying to upload a simple image but the HttpPostedFileBase is always remaining null. This is my code i dont know what i am doing wrong.</p> <p>This is my code in the design view:</p> <pre><code>&lt;fieldset&gt; &lt;legend&gt;PictureModel&lt;/legend&gt; &lt;div class="editor-label"&gt; &lt;%: Html.LabelFor(model =&gt; model.PrivacyTypeID) %&gt; &lt;/div&gt; &lt;div class="editor-field"&gt; &lt;%: Html.DropDownList("PrivacyTypeID", null, new { name = "PrivacyTypeID", title = "Please select privacy type.", id = "PrivacyTypeID" }) %&gt; &lt;%: Html.ValidationMessageFor(model =&gt; model.PrivacyTypeID) %&gt; &lt;/div&gt; &lt;div class="editor-label"&gt; &lt;%: Html.LabelFor(model =&gt; model.File1) %&gt; &lt;/div&gt; &lt;div class="editor-field"&gt; **&lt;input type="file" name="File1" /&gt;** &lt;%: Html.ValidationMessageFor(model =&gt; model.File1) %&gt; &lt;/div&gt; &lt;div class="editor-label"&gt; &lt;%: Html.LabelFor(model =&gt; model.Description) %&gt; &lt;/div&gt; </code></pre> <p>And here is the code in my controller:</p> <p>public ActionResult AddPicture(Guid id, PictureModel model, HttpPostedFileBase File1) { try {</p> <pre><code> if (ModelState.IsValid) { try { Guid albumid = id; if (File1 != null) { var physicalPath = Path.Combine(Server.MapPath("~/Gallery"), System.IO.Path.GetFileName(File1.FileName)); File1.SaveAs(physicalPath); PicturesBL pictures = new PicturesBL(); </code></pre> <p>Can anyone please tell me what is the problem??</p>
 

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