求救http 500内部服务器错误

trueman117 2010-05-15 09:21:59
本人写了个水印处理图片:

在本地debug时没有任何问题:
但是上传至服务器运行时就会报 http 500内部服务器错误
private void UploadImg(string newFileName)
{
//上传大图片

string txt = this.txtProcess.Text;
if (txt == "")
{
txt = "哈哈";
}
string path = Server.MapPath("~/goods/");
//对图片进行水印处理
makeWatermark(10, 10, txt, this.fileupImage.PostedFile.FileName, newFileName, path);
//生成缩略图并上传
string s = Server.MapPath("~/goods/" + newFileName);
string paths = Server.MapPath("~/goods/sGoods/");
SmallPic(s, paths + newFileName, 150, 200);
}
/// <summary>
/// 缩小图片
/// </summary>
/// <param name="strOldPic">源图文件名(包括路径)</param>
/// <param name="strNewPic">缩小后保存为文件名(包括路径)</param>
/// <param name="intWidth">缩小至宽度</param>
/// <param name="intHeight">缩小至高度</param>
public void SmallPic(string strOldPic, string strNewPic, int intWidth, int intHeight)
{
System.Drawing.Bitmap objPic, objNewPic;
try
{


objPic = new System.Drawing.Bitmap(strOldPic);
int width = objPic.Width;
//按比例缩放
double proportion =(double)(125) / width;
int h=Convert.ToInt32( objPic.Height*proportion);
int w= Convert.ToInt32(objPic.Width*proportion);
// objNewPic = new System.Drawing.Bitmap(objPic,Convert.ToInt32(intWidth * proportion) ,Convert.ToInt32( intHeight * proportion));
objNewPic = new System.Drawing.Bitmap(objPic, w, h);
objNewPic.Save(strNewPic);
objPic.Dispose();
objNewPic.Dispose();
}
catch (Exception exp)
{

// this.ClientScript.RegisterStartupScript(this.GetType(), "msg", "alert('" + exp.Message + "!')", true);
throw exp;
}
finally
{
objPic = null;
objNewPic = null;
}

}
/// <summary>
/// 水印处理
/// </summary>
/// <param name="x">文字绘制在图片上的坐标x</param>
/// <param name="y">文字绘制在图片上的坐标x</param>
/// <param name="txt">水印文本</param>
/// <param name="fPath">要处理的图片本地路径</param>
/// <param name="name">保存时的文件名</param>
/// <param name="mPath">上传至服务器的路径</param>

public void makeWatermark(int x, int y, string txt, string fPath, string name, string mPath)
{
// System.Drawing.FontStyle fstyle=new System.Drawing.FontStyle();
try
{
System.Drawing.Image image = System.Drawing.Image.FromFile(fPath);
//实例化绘图对象

System.Drawing.Graphics e = System.Drawing.Graphics.FromImage(image);
//实例化font对象
System.Drawing.Font f = new System.Drawing.Font(System.Drawing.FontFamily.GenericMonospace, 24, System.Drawing.FontStyle.Bold);
//实例化brush
System.Drawing.Brush b = new System.Drawing.SolidBrush(System.Drawing.Color.Gray);

e.DrawString(txt, f, b, image.Width / 15, image.Height / 10);
e.Dispose();

int width = image.Width;

double proportion = (double)(600) / width;

int h = Convert.ToInt32(image.Height * proportion);
int w = Convert.ToInt32(image.Width * proportion);
System.Drawing.Bitmap bt = new System.Drawing.Bitmap(image, w, h);
bt.Save(mPath + name, System.Drawing.Imaging.ImageFormat.Jpeg);
bt.Dispose();
}
catch (Exception exp)
{
// this.ClientScript.RegisterStartupScript(this.GetType(), "msg", "alert('" + exp.Message + "!')", true);
throw exp;
}
}
...全文
86 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
trueman117 2010-05-15
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 caozhy 的回复:]
本地正常但是传上去不正常的,检查:
(1)相对路径、启用父路径、路径权限
(2)数据库权限、配置
(3)服务器是否安装所需组件,尤其是3方组件;asp.net版本
(4)查看日志,启用错误输出,帮助分析。
[/Quote]

我没用什么地第三方组件啊

(4)查看日志,启用错误输出,帮助分析。?这个怎么搞?
threenewbee 2010-05-15
  • 打赏
  • 举报
回复
本地正常但是传上去不正常的,检查:
(1)相对路径、启用父路径、路径权限
(2)数据库权限、配置
(3)服务器是否安装所需组件,尤其是3方组件;asp.net版本
(4)查看日志,启用错误输出,帮助分析。

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧