GDI +一般性错误正在试图保存文件 [英] GDI+ A generic error ... Attempting to save file
问题描述
我一直在学习了不少来自这里的每个人,但我遇到它,我无法找到答案的一个问题。试图保存已使用AsyncFileUpload上传的图片我收到以下错误:GDI +中发生一般性错误。
I've been learning quite a bit from everyone here, however I've come across a problem which I'm having trouble finding an answer to. While attempting to save an image which has been uploaded using AsyncFileUpload I'm receiving the following error: A generic error occurred in GDI+.
我已经做了相当多的谷歌搜索,似乎最有可能的问题是相关的权限。我试着让写/修改网络和Network_Serice。后来试图使其对环境的用户,最后与所有人测试了它 - 遗憾的是它仍然没有工作。
I've done quite a bit of Googling and it seems that the most likely issue is permissions related. I've tried allowing write/modify for Network and Network_Serice. Later attempted allowing it for the environment user and finally tested it with "Everyone" - unfortunately it was still not working.
一个可能的问题是,我依靠内置的开发服务器上的事实。我还是相当新的这一切,所以也不太清楚是否有这方面的任何限制,或者如果我只是忽视的东西明显。
One possible issue is the fact that I'm relying on the built-in development server. I'm still fairly new to it all, so not too sure if there are any limitations in this area or if I'm simply overlooking something obvious.
code:
try
{
//Attempt to convert file to image
uploadedImage = System.Drawing.Image.FromStream(avatarUpload.PostedFile.InputStream);
//Save image
if (uploadedImage != null)
{
//Create vars
String savePath = Server.MapPath("~/Images/Avatars/");
//Save image
uploadedImage.Save(savePath, ImageFormat.Jpeg); !!! Exception raised here
//Dispose of image
uploadedImage.Dispose();
}
}
catch
{
//Create error message
createMessage("Please ensure you select an image i.e. .bmp, .png, .jpg.", "error");
}
如果任何人有任何意见或需要任何更多的信息,请让我知道。
If anyone has any ideas or needs any more info please let me know.
推荐答案
修改
String savePath = Server.MapPath("~/Images/Avatars/");
要
String savePath = Server.MapPath("~/Images/Avatars/myImage.jpg");
这篇关于GDI +一般性错误正在试图保存文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!