本文介绍了如何将图片对象保存到指定目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将要保存的任何图像保存在指定目录中.我已经使用了下面的代码,但是它给出了异常...
Hi,
I want to save any image which i want to save in specified directory..I have used the follwoing code but it is giving exception...
string path = GetImgURL(Picture_id);
System.Drawing.Image _sourceImage = System.Drawing.Image.FromFile(Server.MapPath(path));
System.Drawing.Image _thumbImage = this.CreateThumbnail(_sourceImage, 40, 40);
_thumbImage.Save("~\\Uploads/_thumbImage", ImageFormat.Jpeg);
推荐答案
string filename = Path.GetFileName(fileupload1.FileName);
string filepath = "~/albums/" + filename;
fileupload1.SaveAs(Server.MapPath(filepath));
string path = GetImgURL(Picture_id);
System.Drawing.Image _sourceImage = System.Drawing.Image.FromFile(Server.MapPath(path));
System.Drawing.Image _thumbImage = this.CreateThumbnail(_sourceImage, 40, 40);
_thumbImage.Save( Server.MapPath("~") +"\\Uploads/Day.gif", ImageFormat.Jpeg)
这篇关于如何将图片对象保存到指定目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!