First of all, you cannot send messages directly to the byte array. As a result, you will need a presentation model to represent the product being created / modified. In your view model, your file upload properties should be printed as HttpPostedFileBase:
public HttpPostedFileBase Image1Upload { get; set; }
public HttpPostedFileBase Image2Upload { get; set; }
Your mail action will take your view model as a parameter:
[HttpPost]
public ActionResult CreateProduct(ProductViewModel model)
. :
if (model.Image1Upload != null && model.Image1Upload.ContentLength > 0)
{
using (var ms = new MemoryStream())
{
model.Image1Upload.InputStream.CopyTo(ms);
product.Image1 = ms.ToArray();
}
}
. , , , , .
, .
UPDATE
:
<div class="col-xs-offset-2 col-xs-8 add-item-rectangle">
<input type="file" name="@Model.Photo1" id="file"/>
</div>
-, @Model.Photo1 Model.Photo1, . Razor ToString , name, name="System.Web.HttpPostedFileBase". . :
<input type="file" name="@Html.NameFor(m => m.Photo1)" id="file" />
, , :
@Html.TextBoxFor(m => m.Photo1, new { type = "file" })