【发布时间】:2015-03-16 06:00:58
【问题描述】:
我是 asp.net 的新手,我正在使用 asp.net mvc 4 创建一个网站,用户可以在其中上传任何类型的图像(png、jpeg、gif),但系统会将图像保存为 png格式。我正在使用WebImage 助手。到目前为止上传工作正常,但每当系统保存图像时,文件名看起来像这样,Filename.png.jpeg。这是我来自 Controller 的代码,
if (file != null && file.ContentLength > 0)
{
string picName = "FileName";
WebImage img = new WebImage(file.InputStream);
if (img.Width > 265 || img.Height > 158)
{
img.Resize(265, 158);
}
string picExt = Path.GetExtension(file.FileName);
if (picExt == ".jpg")
{
picExt = ".png";
}
string path = System.IO.Path.Combine(Server.MapPath("~/Images/"), picName + picExt);
img.Save(path);
}
无论用户上传任何格式的图片,我如何才能将图片保存为仅png 格式?非常需要这个帮助。 Tnx。
【问题讨论】:
标签: asp.net asp.net-mvc image