I am trying to upload an image to the database. My code is as follows:
I get the following error:
The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
How can I get this to work ?
VIEW
<div class="form-group">
@Html.LabelFor(model => model.image, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextBoxFor(model => model.image, new { @class = "form-control", type = "file", placeholder = "image" })
@Html.ValidationMessageFor(model => model.image)
</div>
</div>
MODEL
namespace MyPro.Models
{
using System;
using System.Collections.Generic;
public partial class Profile
{
...
public byte[] image{ get; set; }
}
}
CONTROLLER
public async Task<ActionResult> Create([Bind(Include="")] Profile profile)
{
if (ModelState.IsValid)
{
var pro= new Profile{ image = profile.image};
db.Profile.Add(pro);
await db.SaveChangesAsync();
return RedirectToAction("sucess");
}
return View(profile);
}
Database image: