All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
总结优化SQL Server数据库查询的方法_[SQL Server教程]
C#教程:开发UDP聊天程序使用实例
SQL,Server,2008,R2,特色功能盘点_mssql学习_编程技术
ExtJS与.NET结合开发实例(Grid之批量删除篇)_[Asp.Net教程]
单击GridView某行获取该行某列内容并显示_[Asp.Net教程]
PHP和MySQL基础教程(一)_[PHP教程]
.Net中如何操作IIS(源代码)_[Asp.Net教程]
ASP.NET,配置文件层次结构和继承_.net资料_编程技术
两条经典SQL语句(有关日期查询)_[SQL Server教程]
ASP.NET,2.0高级控件之FileUpload控件_[Asp.Net教程]
Reading number is top 10 pictures
赵惟依写真1
Kim jong il's mistress, national beauty JinYuJi actor2
In the world the most mysterious 21 place landscape4
毕姥爷事件,告诉你6条真理
如果没有好报,为什么要做好人?
赵惟依写真2
湖南中医院的养生八图
初吻给了谁?
Is said to be a Chinese female artist fame explicit pictures before2
南昌铁路局宜春车务段攸县车站铁路职工福利房被开发商侵占
Download software ranking
Take off clothes to survival
Tram sex maniac 2 (H) rar bag5
Kung fu panda - the secret of the teacher
Tram sex maniac 2 (H) rar bag11
Unix video tutorial5
美女写真1
C#与.NET技术平台实战演练
Be there or be square
Tram sex maniac 2 (H) rar bag17
asp.net技术内幕
delv published in(发表于) 2014/1/24 9:09:22 Edit(编辑)
C#编写的生成缩略图程序_[Asp.Net教程]

C#编写的生成缩略图程序_[Asp.Net教程]

C#编写的生成缩略图程序_[Asp.Net教程]

if(fileupload.PostedFile!=null)
{
//addto为要添加的属性,aboutfile为文件说明
string nam = fileupload.PostedFile.FileName ;
//取得文件名(抱括路径)里最后一个"."的索引
int i= nam.LastIndexOf(".");
//取得文件扩展名
string newext =nam.Substring(i);
//这里我自动根据日期和文件大小不同为文件命名,确保文件名不重复
DateTime now = DateTime.Now;
string newname=now.DayOfYear.ToString()+fileupload.PostedFile.ContentLength.ToString();
//保存文件到你所要的目录,这里是IIS根目录下的upload目录.你可以改变.
//注意: 我这里用Server.MapPath()取当前文件的相对目录.在asp.net里"\"必须用"\\"代替,把"upload\\"改成"\\upload\\"就成了取当前文件的绝对目录了
fileupload.PostedFile.SaveAs(Server.MapPath("upload\\"+newname+newext));
//得到这个文件的相关属性:文件名,文件类型,文件大小
//fname.Text=myFile.PostedFile.FileName;
//fenc.Text=myFile.PostedFile.ContentType ;
//fsize.Text=myFile.PostedFile.ContentLength.ToString();
//下面是生成缩略图
System.Drawing.Image image,aNewImage;
int width,height,newwidth,newheight;
image=System.Drawing.Image.FromFile(Server.MapPath("upload/"+newname.ToString()+newext.ToString()));
System.Drawing.Image.GetThumbnailImageAbort callb =new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
width=image.Width;
height=image.Height;
if(firstpageshow.SelectedValue.ToString()=="1"&&fenlei.SelectedValue.ToString()=="5")
{
newwidth=203;newheight=86;
newheight=height*newwidth/width;
}
else if(isweekman.SelectedValue.ToString()=="1")
{
newwidth=171;newheight=111;
newheight=height*newwidth/width;
}
else if(firstpageshow.SelectedValue.ToString()=="1"&&fenlei.SelectedValue.ToString()=="3")
{
newwidth=171;newheight=111;
newheight=height*newwidth/width;
}
else
{
newwidth=62;newheight=80;
newheight=height*newwidth/width;
}
aNewImage=image.GetThumbnailImage(newwidth,newheight,callb,new System.IntPtr());
aNewImage.Save(Server.MapPath("upload\\"+"small_"+newname+newext));
image.Dispose();
//生成缩略图 生成并保存完毕,保存名是在原图名前加了一个small_。
pic="upload/"+newname.ToString()+newext.ToString();
smallpic="upload/small_"+newname.ToString()+newext.ToString();
}

作者:清清月儿







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.