Hello everyone,
I am working on MVC 5, I want to upload and save images on application's local folder.
This is view,
After the upload, now getting 2 images on Controller,
I want to save Logo Images on this path
- string path = Server.MapPath("~") + "UploadedImages/PremiUserRegistration/LogoImage/" + file.FileName;
And, Tittile Images on this path
- string path = Server.MapPath("~") + "UploadedImages/PremiUserRegistration/TitlePicture/" + file.FileName;
I have tried,
- foreach (HttpPostedFileBase item in fileUpload)
- {
- if (item.ContentLength > 0)
- {
- HttpFileCollectionBase files = Request.Files;
- DataTable dt = new DataTable { Columns = { new DataColumn("Path") } };
- for (int i = 0; i < files.Count; i++)
- {
- HttpPostedFileBase file = files[i];
- string path = Server.MapPath("~") + "UploadedImages/PremiUserRegistration/LogoImage/" + file.FileName;
-
-
- if (file.FileName != "")
- {
- dt.Rows.Add(file.FileName);
- file.SaveAs(path);
- }
- }
- }
- }
How can I do this? Please help me...