Image Resizing On Uploadig
Literature
[HttpPost]
public ActionResult index(HttpPostedFileBase file)
{
if(file!=null)
{
WebImage img = new WebImage(file.InputStream);
img.Resize(150, 150);
if (img.Width==150 )
{
string path = Path.Combine(Server.MapPath("~/Images/Size150/"),
Path.GetFileName(file.FileName));
img.Save(path);
}
img.Resize(250, 250);
if (img.Width == 250)
{
string path = Path.Combine(Server.MapPath("~/Images/Size250/"),
Path.GetFileName(file.FileName));
img.Save(path);
}
ImageTable imgagtbl = new ImageTable();
imgagtbl.ImageURL = file.FileName;
db.ImageTables.Add(imgagtbl);
db.SaveChanges();
ViewBag.Message = "File uploaded successfully";
}
return RedirectToAction("ShowImage");
}
Share This with your friend by choosing any social account