index()
HOmeController
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<BL7HRIS.Models.ImageModal>" %> <script src="<%: Url.Content("~/Scripts/jquery-1.7.1.min.js") %>"></script> <script src="<%: Url.Content("~/Scripts/jquery.validate.min.js") %>"></script> <script src="<%: Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js") %>"></script> <% using (Html.BeginForm("Upload","Home", FormMethod.Post)) { %> <%: Html.ValidationSummary(true) %> <div> <input name="ImageUploaded" type="file"> <input type="submit"> <%:ViewBag.path2%> </p> </div> <% } %> <div> <%: Html.ActionLink("Back to List", "Index") %> </div> <p> <img src="Content/Images/Full/<%=ViewBag.path2%>.jpg" alt="No IMAGE UPLOADED" width="304" height="228" /></p>
public ActionResult Index() //for image uploader if (fileName != "") { ViewBag.path2 = fileName; fileName = ""; } else { ViewBag.path2 = "No IMAGE!"; } //return View("Index"); } //image uploader return View(); } // upload method is here [HttpPost] public ActionResult Upload(ImageModal model) { if (ModelState.IsValid) { // string fileName = Guid.NewGuid().ToString(); string fileName = "A00001"; fileName = "A00001"; string serverPath = Server.MapPath("~"); string imagesPath = serverPath + "Content\\empImages\\"; string thumbPath = imagesPath + "Thumb\\"; string fullPath = imagesPath + "Full\\"; ImageModal.ResizeAndSave(thumbPath, fileName, model.ImageUploaded.InputStream, 80, true); ImageModal.ResizeAndSave(fullPath, fileName, model.ImageUploaded.InputStream, 600, true); anyone have any suggestions? Thanks a lot ? Note this is a partial class and i call this partial class from another view called index :) } return RedirectToAction("Index"); } //---------added by heshan for image uploader----// }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)