Hello Team, Please can anyone help me with a code on how to upload pdf, word document etc files into a directory in systematic orde, my project is in ASP.net MVC, thank you
Loading
Hello Team, Please can anyone help me with a code on how to upload pdf, word document etc files into a directory in systematic orde, my project is in ASP.net MVC, thank you
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Vishal JoshiRank #377 · 6.7K reputationPosted Mar 4, 2024, 12:38 AM EST
Hello Emmanuel,
Please try the below given code.
Controller Code
public ActionResult FillingDocument(HttpPostedFileBase file) { try { if (file.ContentLength > 0) { string _FileName = Path.GetFileName(file.FileName); string _path = Path.Combine(Server.MapPath("~/UploadedFiles"), _FileName); file.SaveAs(_path); } ViewBag.Message = "File Uploaded Successfully!!"; List files = new DirectoryInfo(Server.MapPath("~/UploadedFiles")).GetFiles().ToList().Select(a => a.Name).ToList(); return View(files); } catch { ViewBag.Message = "File upload failed!!"; return View(); } }View Code
@using (Html.BeginForm("FillingDocument", "Home", FormMethod.Post, new { enctype = "multipart/form-data" })) { @Html.TextBox("file", "", new { type = "file" }) upload file @ViewBag.Message }Thank you
Vishal Joshi
Rajanikant HawaldarRank #110 · 20.2K reputationPosted Mar 2, 2024, 7:58 AM EST
Hello Emm....
go through below article
https://www.c-sharpcorner.com/article/upload-files-in-asp-net-mvc-5/
Emmmanuel FIADUFERank #947 · 2.2K reputationPosted Mar 2, 2024, 10:50 AM EST
Thank you Hawaldar, I will check it and revert
Prasad RaveendranRank #320 · 7.8K reputationPosted Mar 2, 2024, 9:09 PM EST
check the below link if you are looking for upload functionality in ASP.NET Core aPI
https://www.c-sharpcorner.com/blogs/upload-files-using-asp-net-core-api2
Jignesh KumarRank #91 · 22.9K reputationPosted Mar 3, 2024, 10:39 PM EST
Hello,
Please refer to this article on .net mvc and SQL server,
https://www.c-sharpcorner.com/article/asp-net-mvc5-upload-imagefile-into-database/
If you want to store in binary format then please refer this one,
https://www.c-sharpcorner.com/article/upload-files-and-save-into-database-in-binary-format-using-asp-net/
Emmmanuel FIADUFERank #947 · 2.2K reputationPosted Mar 4, 2024, 11:29 AM EST
Thank you team it is working now