Image Resizing On Uploadig
Image Resizing On Uploadig
[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
You may also read following recent articles
![]() |
5 English Habits to Practice Every Day to Improve English Fluency and Communication Skills!
Junaid A 10-Mar-2023 |
![]() |
Reseed the Identity field in ms sql server!
Junaid A 02-Mar-2023 |
![]() |
what is Prompt engineering!
Junaid A 01-Mar-2023 |
![]() |
Useful code for ASP .Net Developer!
Junaid A 24-Feb-2023 |
![]() |
Expert Networks website!
Junaid A 22-Feb-2023 |
![]() |
best mobile app for WhatsApp call recording!
Junaid A 22-Feb-2023 |
![]() |
chat gpt extensions for google chrome!
Junaid A 22-Feb-2023 |
![]() |
Is Chat GPT Use Of Web Content Fair!
Junaid A 29-Jan-2023 |
![]() |
Office politics examples!
Junaid A 28-Jan-2023 |
![]() |
ten jokes about the status of ChatGPT!
Junaid A 17-Jan-2023 |
![]() |
Image Resizing On Uploadig!
shahid Riaz 02-Jan-2019 |