<div style="float:left; margin-left:100px"> Upload Image <input type="file" name="image_icon" id="img" /> </div>
public ActionResult Create(FormCollection collection, sampleViewModel sampleVM, HttpPostedFileBase image) { try { //if (image != null) if(sampleVM.image_icon!=null) { // var imageName = image.FileName; var imageName = newsVM.image_icon; var filePathOriginal = Server.MapPath("/Content/Image"); //var filePathThumbnail = Server.MapPath("/Content/Uploads/Thumbnails"); string savedFileName = Path.Combine(filePathOriginal, imageName); image.SaveAs(savedFileName); } } }
//Pls check here for reference
http://www.aspdotnet-suresh.com/2014/12/how-to-upload-files-in-asp-net-mvc-razor.html[^]
http://www.c-sharpcorner.com/UploadFile/b696c4/how-to-upload-and-display-image-in-mvc/[^]
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)