I have written this code. I want to upload 2 images in asp.net C# program (image and Gif). I accept image when it's JPG format.
Would you please tell me how to do so?
I read all topic similar to my problem! please don't refer me to them!:)
public ActionResult Upload(HttpPostedFileBase image , HttpPostedFileBase Gif)
{
Image i = Image.FromFile("image.FileName");
if (System.Drawing.Imaging.ImageFormat.Jpeg.Equals(i.RawFormat))
{
string imageName = Path.GetFileName(image.FileName);
string image_path = Server.MapPath("~/Images/" + imageName);
image.SaveAs(image_path);
ViewBag.image_path = image_path;
}
string gifName = Path.GetFileName(Gif.FileName);
string gif_path = Server.MapPath("~/Images/" + gifName);
Gif.SaveAs(gif_path);
ViewBag.gif_path = gif_path;
return View();
}