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.
This is my code in the design view:
<fieldset>
<legend>PictureModel</legend>
<div class="editor-label">
<%: Html.LabelFor(model => model.PrivacyTypeID) %>
</div>
<div class="editor-field">
<%: Html.DropDownList("PrivacyTypeID", null, new { name = "PrivacyTypeID", title = "Please select privacy type.", id = "PrivacyTypeID" }) %>
<%: Html.ValidationMessageFor(model => model.PrivacyTypeID) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.File1) %>
</div>
<div class="editor-field">
**<input type="file" name="File1" />**
<%: Html.ValidationMessageFor(model => model.File1) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.Description) %>
</div>
And here is the code in my controller:
public ActionResult AddPicture(Guid id, PictureModel model, HttpPostedFileBase File1) { try {
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();
Can anyone please tell me what is the problem??