【发布时间】:2016-06-26 16:18:58
【问题描述】:
我已经写了这段代码。我想在 asp.net C# 程序中上传 2 张图片(图片和 Gif)。我接受 JPG 格式的图像。
你能告诉我怎么做吗?
我阅读了所有与我的问题相似的主题!请不要把我介绍给他们!:)
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();
}
【问题讨论】:
-
我有 2 个文件。一张 JPG 格式的图片和另一张 Gif 格式的图片。我不写关于 Gif 条件的那部分@marc_s