HttpPostedFileBase null after reloading the page, (image upload)

0

Is there any way I can not lose data from HttpPostedFileBase ? my action does a check, and in case of failure the page reloads with the image in the form and I have to make the call again, then HttpPostedFileBase will be null, unless I choose the image again.

@{
Dictionary<string, object> htmlAttributes = new Dictionary<string, object>();
htmlAttributes.Add("id", "delivery-form");
htmlAttributes.Add("class", "middle-forms");
htmlAttributes.Add("enctype", "multipart/form-data");
}

@using (Html.BeginForm(actionName, "DeliveryService", ViewBag.Routes as RouteValueDictionary, FormMethod.Post, htmlAttributes @*new { @id = "delivery-form", @class = "middle-forms" }*@))
{

First call:

SecondCall:

UPDATE

OneworkaroundIcameupwithwastouseSessiontosaveHttpPostedFileBasedata,thus:

Session["ImportFile"] = ImportFile;
    
asked by anonymous 13.04.2017 / 18:37

1 answer

-1

I do this, I create a table that saves image information, such as, path, name, extension, etc ... so you can upload via ajax, using angum plugin, and return the id of it, so in submit you send this id along with the model, and it treats in the backend

    
18.04.2017 / 18:52