When I try to load images into the action of my MVC controller and a validation error occurs, I have to click each of the buttons and again find all my files.
If I have a view consisting of
<input type="file" id="file0" name="Files[0]" /> <input type="file" id="file1" name="Files[1]" />
and controller actions, for example
public ActionResult Create(ModelClass model, IEnumerable<HttpPostedFileBase> Files) { if(ModelState.IsValid) { //do work if(PhotoValidation.IsValid(Files)) { //do work } else { ModelState.AddModelError("","Photos not valid"); } } return view(model); // Way to return photos back to the view on modelstate error? }
Files can be sent to the server in order, but if there is an error checking the model, is there a way to return the model AND the files so that the user does not upload them again?
source share