GDI +中发生了一般错误。 (只有我在服务器上试试) [英] A generic error occurred in GDI+. (Only if i try it on the server)

查看:232
本文介绍了GDI +中发生了一般错误。 (只有我在服务器上试试)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我的调整大小并将img上传到服务器有问题。一切都还可以,但今天告诉我朋友,当他想要将img添加到服务器时,他得到GDI +中发生了一般错误。..但在我的电脑上一切正常。那么IIS可能有问题吗? (两天前他有一些问题,所以管理员在服务器上改变了一些东西。)

Hello I have problem with my resizing and uploading img to server. Everything was ok, but today tell me friend when he want add img to server, he gets "A generic error occurred in GDI+.".. But in my PC all works fine. So can be problem with IIS? (Two days ago he had some problem so admin change something on server).

Bitmap image = KTEditImage.ResizeImage(new Bitmap(file.PostedFile.InputStream), 360, 360);
image.Save(Server.MapPath("~") + "/Static/Img/Zbozi/" + urlName, ImageFormat.Jpeg);
image.Dispose();
Bitmap smallImage = KTEditImage.ResizeImage(new Bitmap(file.PostedFile.InputStream), 230, 230);                           
smallImage.Save(Server.MapPath("~") + "/Static/Img/Zbozi/Small/" + urlName, ImageFormat.Jpeg);
smallImage.Dispose();

并且调整大小的方法是

public static Bitmap ResizeImage(Bitmap image, int maxWidth, int maxHeight)
{
    return new Bitmap(image, maxWidth, maxHeight);
}


推荐答案

授予目标写入权限目录到ASPNET帐户(Windows XP)或NETWORK SERVICE帐户(Windows Server 2003/2008 / Vista / 7),

Grant write permission on the target directory to ASPNET account(Windows XP) or NETWORK SERVICE account(Windows Server 2003/2008/Vista/7),

这篇关于GDI +中发生了一般错误。 (只有我在服务器上试试)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆