3
Answers

Error "The input is not a valid Base-64 string..."

Shibly  Sadik

Shibly Sadik

9y
2.3k
1
I am getting the follwing error while editing my database..
 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.
//My model:
public class Document
{
[Key]
public int DocID { get; set; }
public byte[] ImageData { get; set; }
}

public class ImageContext:DbContext
{
public DbSet<Document> Documents { get; set; }
}

//Controller:
[HttpPost]
public ActionResult Edit(int id, Document d, HttpPostedFileBase file)
{
try
{
db.Entry(d).State = System.Data.Entity.EntityState.Modified;
db.SaveChanges();
return RedirectToAction("List");
}
catch
{
return View();
}
}
//My Edit View:
@Html.LabelFor(model => model.ImageData, new { @class = "control-label col-md-2" })
@Html.TextBoxFor(model => model.ImageData, new { type="file",name="file"}) 
<input type="submit" value="Save" class="btn btn-default" />

I can  add,delete image but cant edit...
 What can i do ..help please..
Answers (3)