在ASP.NET中上传图片并生成缩略图
private void btnUploadPicture_Click(object sender, System.EventArgs e)
{
//检查上传文件的格式是否有效
if(this.UploadFile.PostedFile.ContentType.ToLower().IndexOf("image") < 0)
{
Response.Write("上传图片格式无效!");
return;
}
//生成原图
Byte[] oFileByte = new byte[this.UploadFile.PostedFile.ContentLength];
System.IO.Stream oStream = this.UploadFile.PostedFile.InputStream;
System.Drawing.Image oImage = System.Drawing.Image.fromStream(oStream);
int oWidth = oImage.Width; //原图宽度
int oHeight = oImage.Height; //原图高度
int tWidth = 100; //设置缩略图初始宽度
int tHeight = 100; //设置缩略图初始高度
//按比例计算出缩略图的宽度和高度
if(oWidth >= oHeight)
{
tHeight = (int)Math.Floor(Convert.ToDouble(oHeight) * (Convert.ToDouble(tWidth) / Convert.ToDouble(oWidth)));
}
else
{
tWidth = (int)Math.Floor(Convert.ToDouble(oWidth) * (Convert.ToDouble(tHeight) / Convert.ToDouble(oHeight)));
}
//生成缩略原图
Bitmap tImage = new Bitmap(tWidth,tHeight);
Graphics g = Graphics.fromImage(tImage);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; //设置高质量插值法
g.SmoothingMode = System.Drawin
相关文档:
在ASP.NET中调用EXCEL组件的时候,如果没有配置DCOM中EXCEL权限问题,结果程序会报:Access is denied.
解决的方法有两种:
第一种,在web.config中设置一个节点.
<identity impersonate="true" />
不过这种方法只能解决local电脑上的Excel Access is denied的问题
如果是服务器的话,有客户机访问页面的时候, ......
前阵子开发的一个项目程序中,总是存在超时问题,我在iis和web.config中都配置了超时为120分钟,但是经常是不到40分钟就超时了,很是烦人却苦于一直没有找到比较好的一种方案,后来查询了许多相关的资料才找到一个可以实施的方案。
这里主要讲述一下web.config关于sessionState节点的配置方案,sessionState有四种模式:of ......
今天第一天开通了博客,心情乐滋滋的,因为可以和园子里的朋友一起研究技术了。我希望把平时在项目中积累的知识以及自己学习的知识同园子里的朋友分享分享。为我们园子的壮大付出自己的一点努力。这是我发表的第二篇话题,希望对这<%%>语法不熟悉的朋友提供帮助,对已经熟悉的朋友,希望能提出你们宝贵的意见。
在a ......
网络文本编辑器----Fckeditor之使用篇
1.下载Fckeditor,asp.net版分两部分,FCKeditor和FCKeditor.Net: ASP.Net Control。
官方网站:http://ckeditor.com/download
2.Fckeditor在项目中的集成。
很简单,不再赘述。
参考文献:http://www.cnblogs.com/zhubo/archive/2008/10/21/using_fckeditor_net.html
常 ......
1.符号“/”指程序运行所在根目录,即IIs所在目录。
如果iis所在目录为:d:\programs
解决方案为d:\programs\d
网站路径为:d:\programs\d\web\
符号“/”代表的是:d:\programs,不管你的网站前面有多少级,都应该作为一个整体。
2.符号“~/”,则是指网站所在根目录。即d:\programs\ ......