Possible Duplicate:
How to generate square thumbnail of an image?
I’m trying to save my image as thumbnail. How can I do this ?
Here is my action control:
[HttpPost]
[ValidateInput(false)]
public ActionResult banner_create(banner banner, HttpPostedFileBase file)
{
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("~/banner_image/"), fileName);
var extension = Path.GetExtension(path);
file.SaveAs(path);
banner.banner_image_description = extension;
banner.banner_image_name = fileName;
if (ModelState.IsValid)
{
db.banner.AddObject(banner);
db.SaveChanges();
return RedirectToAction("index");
}
return View(banner);
}
The following code should work fine.
I’ve added some comments, so you can see what’s going on.