ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Upload File from Popup using controller and not ajax
Title:
B
I
{code}
?
I need to upload excel file and it's working fine from the home page but the same code doesn't from a popup. Do you please have any working example ? The sample code I found on the web: View: <form asp-controller="Home" asp-action="UploadFileViaModel" method="post" enctype="multipart/form-data"> @Html.EditorFor(m => m.FileToUpload, new { type = "file" }) <button type="submit">Upload File (model)</button> </form> Controller: [HttpPost] public async Task<IActionResult> UploadFileViaModel(FileInputModel model) { if (model?.FileToUpload == null || model.FileToUpload.Length == 0) return Content("file not selected !"); var path = Path.Combine(Directory.GetCurrentDirectory(), UPLOAD_FOLDER, model.FileToUpload.GetFilename()); using (var stream = new FileStream(path, FileMode.Create)) { await model.FileToUpload.CopyToAsync(stream); } return RedirectToAction("Files"); } If I paste same code in my popup view with off course is rendered as partial-view, the files parameter in the controller is always empty Do you see any reason the partial view or popup or any other ??? is causing this ?
Save Changes
Cancel
vRITHNER
asked at 10 Dec 2017
https://www.aspnetawesome.com/forum/question/813/file-upload-in-popupform-returning-null-request
at 10 Dec 2017
Omu
Answers
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK