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)
{
Application["count"] = 0;
}
void Application_End(object sender, EventArgs e)
{ }
void Application_Error(object sender, EventArgs ......
+++ Cookie01.aspx页面
++ 页面代码如下:
<asp:TextBox ID="TextBox1" runat="server" ForeColor="Red" Width="182px">Name</asp:TextBox>
<asp:Button ID="BtnCookie" runat="server" OnClick="BtnCookie_Click" Text="BtnCookie" /><br />
++ 后台代码如下:
protected void BtnCookie_Cl ......
+++ HiddenField01.aspx页面
++ 页面代码如下:
<asp:HiddenField ID="HiddenField1" runat="server" />
<asp:HiddenField ID="HiddenField2" runat="server" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
++ 后台代码,如下:
protected void Button1_C ......
1、直接将页面内容存在变量中后输出:
StringBuilder IndexContentResult= new StringBuilder(); //存放输出页面的HTML
IndexContentResult.Append("<html>\n");
IndexContentResult.Append(&qu ......
使用flash开发的SWFUpload上传组件有很多好处,支持进度条是其中一种好处,下面是asp.net封装SWFUpload下载地址:
效果图:
如果直接拷贝SWFUpload文件夹到你的项目
记得必须引用SWFUploadAPI.dll
点击此处下载:SWFUpload.rar
文章来自学IT网:http://www.xueit.com/html/2010-05/21-12561321642010518215213640 ......