asp.net 等比例生成上传图片的高质量缩略图的方法
方法1
HttpFileCollection files = HttpContext.Current.Request.Files;
//我设置的大小不超过A4纸的缩略图
int newWidth=620;
int newHeight=880;
System.Drawing.Image img = null;
for(int iFile = 0; iFile < files.Count; iFile++)
{
///检查文件扩展名字
HttpPostedFile postedFile = files[iFile];
string fileName, fileExtension;
fileName = System.IO.Path.GetFileName(postedFile.FileName);
if (fileName != "")
{
fileExtension = System.IO.Path.GetExtension(fileName);
string name=DateTime.Now.ToString("yyyyMMddHHmmssffffff")+iFile+fileExtension;
string filePath=System.Web.HttpContext.Current.Request.MapPath(@"UpdatePic/") + name;
if (fileExtension.ToLower()==".jpg" || fileExtension.ToLower()==".gif" || fileExtension.ToLower()==".png")
{
//图片大小限制在1K到2M之间
if(postedFile.ContentLength>=1024 && postedFile.ContentLength<=20480000 && postedFile.ContentType.ToString().ToLower().IndexOf("image") >= 0)
{
img = System.Drawing.Image.fromStream(postedFile.InputStream);
&nb
相关文档:
例一:
+++ 修改Global.asax文件:
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{ }
void Application_End(object sender, EventArgs e)
{ }
void Application_Error(object sender, EventArgs e)
{ }
void ......
+++ 修改Global.asax文件:
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
Application["count"] = 0;
}
void Application_End(object sender, EventArgs e)
{ }
void Application_Error(object sender, EventArgs ......
第一步 掌握一门.NET面向对象语言,C#或VB.NET 我强烈反对在没系统学过一门面向对象(OO)语言的前提下去学ASP.NET。 ASP.NET是一个全面向对象的技术,不懂OO,那绝对学不下去!
第二步 对.NET Framework类库有一定的了解 可以通过开发Windows Form应用程序来学习.NET Framework。ASP.NET是建构在.NET Framework之上的 ......
MVC2 框架安装完成以后我们就可以开始我们的 MVC之旅了,呵呵
本次学习内容:Route
首先 route 的中文意思就是我们常说的“路由”,确实这里也是这个意思,在我们MVC中已经不再使用 XX.aspx 来访问页面了,
所有页面的请求会通过route来解析找到对应的控制器(controller)里面对应的操作(action)来执行的。
mv ......