Hi sani.ss501,
Refer below sample.
Database
CREATE TABLE tbl_user
(
id int IDENTITY PRIMARY KEY,
name nvarchar(100),
image nvarchar(max),
resume nvarchar(max)
)
Controller
public class HomeController : Controller
{
// GET: Home
public ActionResult Index()
{
return View();
}
public ActionResult Upload(tbl_user user)
{
HttpPostedFileBase postedFileImage = Request.Files["postedFileImage"];
HttpPostedFileBase postedFileResume = Request.Files["postedFileResume"];
string pathImage = Server.MapPath("~/Image/");
string pathResume = Server.MapPath("~/Resume/");
if (!Directory.Exists(pathImage))
{
Directory.CreateDirectory(pathImage);
}
if (!Directory.Exists(pathResume))
{
Directory.CreateDirectory(pathResume);
}
postedFileImage.SaveAs(pathImage + Path.GetFileName(postedFileImage.FileName));
postedFileResume.SaveAs(pathResume + Path.GetFileName(postedFileResume.FileName));
user.image = "Image/" + Path.GetFileName(postedFileImage.FileName);
user.resume = "Resume/" + Path.GetFileName(postedFileResume.FileName);
UserEntities entity = new UserEntities();
entity.tbl_user.Add(user);
entity.SaveChanges();
return RedirectToAction("Index");
}
}
View
@model Multiple_FileUpload_MVC.tbl_user
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
@using (Html.BeginForm("Upload", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<table>
<tr>
<td>Name</td>
<td>@Html.TextBoxFor(m => m.name)</td>
</tr>
<tr>
<td>Image</td>
<td><input type="file" name="postedFileImage" /></td>
</tr>
<tr>
<td>Resume</td>
<td><input type="file" name="postedFileResume" /></td>
</tr>
</table>
<hr />
<input type="submit" value="Upload" />
}
</body>
</html>