Image Resizing On Uploadig

By shahid Riaz   Posted on January-02-2019   430

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");
        }

Quotation by Hurbert hoover
By shahid Riaz    02-Jan-2019 Views  430



You may also read following recent articles