Hai friends,
How to save the images in solution explorer & its path in database.
& should be able to download.
please provide me solution.
Thank you.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vincent Maverick DuranoPosted Apr 26, 2015, 3:22 AM
Googling the term should give you lots of examples in the web, here are some of them:
http://byatool.com/mvc/asp-net-mvc-upload-image-to-database-and-show-image-dynamically-using-a-view/
http://www.codeproject.com/Articles/708140/Uploading-and-Viewing-Images-With-ASP-Net-MVC-and
Vijay SaklaniPosted Apr 25, 2015, 2:44 AM
Controller:
View :
If you get any problem to implement . visit the the below given link:
http://www.articlemirror.in/2014/02/file-upload-and-save-path-to-database.html
Manoj BhoirPosted Apr 18, 2015, 5:31 AM
Model :
public class MyViewModel
{
[Required]
public HttpPostedFileBase File { get; set; }
}
Controller :
public class HomeController: Controller
{
public ActionResult Index()
{
var model = new MyViewModel();
return View(model);
}
[HttpPost]
public ActionResult Index(MyViewModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}
byte[] uploadedFile = new byte[model.File.InputStream.Length];
model.File.InputStream.Read(uploadedFile, 0, uploadedFile.Length);
// now you could pass the byte array to your model and store wherever
// you intended to store it
return Content("Thanks for uploading the file");
}
}
View :
@model MyViewModel
@using (Html.BeginForm(null, null, FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.LabelFor(x => x.File)
@Html.TextBoxFor(x => x.File, new { type = "file" })
@Html.ValidationMessageFor(x => x.File)
}
Reference : http://stackoverflow.com/questions/15106190/uploading-files-into-database-with-asp-net-mvc