【.NET】上传文件,生成缩略图
类名:Upload
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Util; namespace Tools
{
/// <summary>
/// UploadPic 的摘要说明。
/// </summary>
public class UploadPic
{
#region 构造函数
public UploadPic()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
#endregion
#region 上传图片,并生成缩略图
public string upload(System.Web.UI.HtmlControls.HtmlInputFile UploadFile, int tWidth, int tHeight)
{
string result = "";
//检查上传文件的格式是否有效
if(UploadFile.PostedFile.ContentType.ToLower().IndexOf("image") < )
{
result = "上传图片格式无效!";
return result;
} //生成原图
Byte[] oFileByte = new byte[UploadFile.PostedFile.ContentLength];
System.IO.Stream oStream = UploadFile.PostedFile.InputStream;
System.Drawing.Image oImage = System.Drawing.Image.FromStream(oStream); int oWidth = oImage.Width; //原图宽度
int oHeight = oImage.Height; //原图高度
if(oWidth < tWidth && oHeight < tHeight)
{
result = "smaller";
return result;
}
//按比例计算出缩略图的宽度和高度
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.Drawing.Drawing2D.SmoothingMode.HighQuality;//设置高质量,低速度呈现平滑程度
g.Clear(Color.Transparent); //清空画布并以透明背景色填充
g.DrawImage(oImage, new Rectangle(, , tWidth, tHeight), new Rectangle(, , oWidth, oHeight), GraphicsUnit.Pixel);
string file = DateTime.Now.ToShortDateString().Replace("-", "").Replace("/", "").Replace("/", "") + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + ".jpg";
string oFullName = System.Web.HttpContext.Current.Server.MapPath("../../UploadImg/") + file;//保存原图的物理路径
string tFullName = System.Web.HttpContext.Current.Server.MapPath("../../UploadImg/") + file; //保存缩略图的物理路径
result = file;
try
{
//以JPG格式保存图片
oImage.Save(oFullName, System.Drawing.Imaging.ImageFormat.Jpeg);
tImage.Save(tFullName, System.Drawing.Imaging.ImageFormat.Jpeg);
}
catch(Exception ex)
{
throw ex;
}
finally
{
//释放资源
oImage.Dispose();
g.Dispose();
tImage.Dispose(); }
return result;
}
public string uploadPNGSIZE(System.Web.UI.HtmlControls.HtmlInputFile UploadFile, int tWidth, int tHeight)
{
string result = "";
//检查上传文件的格式是否有效
if(UploadFile.PostedFile.ContentType.ToLower().IndexOf("image") < )
{
result = "上传图片格式无效!";
return result;
} //生成原图
Byte[] oFileByte = new byte[UploadFile.PostedFile.ContentLength];
System.IO.Stream oStream = UploadFile.PostedFile.InputStream;
System.Drawing.Image oImage = System.Drawing.Image.FromStream(oStream); int oWidth = oImage.Width; //原图宽度
int oHeight = oImage.Height; //原图高度
if(oWidth < tWidth && oHeight < tHeight)
{
result = "smaller";
return result;
}
//按比例计算出缩略图的宽度和高度
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.Drawing.Drawing2D.SmoothingMode.HighQuality;//设置高质量,低速度呈现平滑程度
g.Clear(Color.Transparent); //清空画布并以透明背景色填充
g.DrawImage(oImage, new Rectangle(, , tWidth, tHeight), new Rectangle(, , oWidth, oHeight), GraphicsUnit.Pixel);
string file = DateTime.Now.ToShortDateString().Replace("-", "").Replace("/", "").Replace("/", "") + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + ".jpg";
string oFullName = System.Web.HttpContext.Current.Server.MapPath("../../images/") + file;//保存原图的物理路径
string tFullName = System.Web.HttpContext.Current.Server.MapPath("../../images/") + file; //保存缩略图的物理路径
result = file;
try
{
//以JPG格式保存图片
oImage.Save(oFullName, System.Drawing.Imaging.ImageFormat.Png);
tImage.Save(tFullName, System.Drawing.Imaging.ImageFormat.Png);
}
catch(Exception ex)
{
throw ex;
}
finally
{
//释放资源
oImage.Dispose();
g.Dispose();
tImage.Dispose(); }
return result;
} #endregion public string upload_watermark(System.Web.UI.HtmlControls.HtmlInputFile UploadFile, int tWidth, int tHeight)
{
string filetype = System.IO.Path.GetExtension(UploadFile.PostedFile.FileName);
string result = "";
//检查上传文件的格式是否有效
if(UploadFile.PostedFile.ContentType.ToLower().IndexOf("image") < )
{
result = "上传图片格式无效!";
return result;
} //生成原图
Byte[] oFileByte = new byte[UploadFile.PostedFile.ContentLength];
System.IO.Stream oStream = UploadFile.PostedFile.InputStream;
System.Drawing.Image oImage = System.Drawing.Image.FromStream(oStream);
//加水印
System.Drawing.Image copyImage = System.Drawing.Image.FromFile(System.Web.HttpContext.Current.Server.MapPath("../../UploadImg/") + "watermark.png");
Graphics g_water = Graphics.FromImage(oImage);
g_water.DrawImage(copyImage, new Rectangle(oImage.Width - copyImage.Width, , copyImage.Width, copyImage.Height), , , copyImage.Width, copyImage.Height, GraphicsUnit.Pixel);
g_water.Dispose(); int oWidth = oImage.Width; //原图宽度
int oHeight = oImage.Height; //原图高度
if(oWidth < tWidth && oHeight < tHeight)
{
result = "smaller";
return result;
}
//按比例计算出缩略图的宽度和高度
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.Drawing.Drawing2D.SmoothingMode.HighQuality;//设置高质量,低速度呈现平滑程度
g.Clear(Color.Transparent); //清空画布并以透明背景色填充
g.DrawImage(oImage, new Rectangle(, , tWidth, tHeight), new Rectangle(, , oWidth, oHeight), GraphicsUnit.Pixel);
string file = DateTime.Now.ToShortDateString().Replace("-", "").Replace("/", "").Replace("/", "") + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + filetype;
string oFullName = System.Web.HttpContext.Current.Server.MapPath("../../UploadImg/") + file;//保存原图的物理路径
string tFullName = System.Web.HttpContext.Current.Server.MapPath("../../UploadImg/") + file; //保存缩略图的物理路径
result = file;
try
{
//以不同格式保存图片
if(filetype.Trim().ToLower().CompareTo(".png") == )
{
oImage.Save(oFullName, System.Drawing.Imaging.ImageFormat.Png);
tImage.Save(tFullName, System.Drawing.Imaging.ImageFormat.Png);
}
else
{
oImage.Save(oFullName, System.Drawing.Imaging.ImageFormat.Jpeg);
tImage.Save(tFullName, System.Drawing.Imaging.ImageFormat.Jpeg);
} }
catch(Exception ex)
{
throw ex;
}
finally
{
//释放资源
oImage.Dispose();
g.Dispose();
tImage.Dispose(); }
return result;
}
public string upload_watermark_origin(System.Web.UI.HtmlControls.HtmlInputFile UploadFile)
{
int tWidth = , tHeight = ;
string filetype = System.IO.Path.GetExtension(UploadFile.PostedFile.FileName);
string result = "";
//检查上传文件的格式是否有效
if(UploadFile.PostedFile.ContentType.ToLower().IndexOf("image") < )
{
result = "上传图片格式无效!";
return result;
} //生成原图
Byte[] oFileByte = new byte[UploadFile.PostedFile.ContentLength];
System.IO.Stream oStream = UploadFile.PostedFile.InputStream;
System.Drawing.Image oImage = System.Drawing.Image.FromStream(oStream);
//加水印
System.Drawing.Image copyImage = System.Drawing.Image.FromFile(System.Web.HttpContext.Current.Server.MapPath("../../UploadImg/") + "watermark.png");
Graphics g_water = Graphics.FromImage(oImage);
g_water.DrawImage(copyImage, new Rectangle(oImage.Width - copyImage.Width, , copyImage.Width, copyImage.Height), , , copyImage.Width, copyImage.Height, GraphicsUnit.Pixel);
g_water.Dispose(); int oWidth = oImage.Width; //原图宽度
tWidth = oWidth;
int oHeight = oImage.Height; //原图高度
tHeight = oHeight; if(oWidth < tWidth && oHeight < tHeight)
{
result = "smaller";
return result;
}
//按比例计算出缩略图的宽度和高度
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.Drawing.Drawing2D.SmoothingMode.HighQuality;//设置高质量,低速度呈现平滑程度
g.Clear(Color.Transparent); //清空画布并以透明背景色填充
g.DrawImage(oImage, new Rectangle(, , tWidth, tHeight), new Rectangle(, , oWidth, oHeight), GraphicsUnit.Pixel);
string file = DateTime.Now.ToShortDateString().Replace("-", "").Replace("/", "").Replace("/", "") + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + filetype;
string oFullName = System.Web.HttpContext.Current.Server.MapPath("../../UploadImg/") + file;//保存原图的物理路径
string tFullName = System.Web.HttpContext.Current.Server.MapPath("../../UploadImg/") + file; //保存缩略图的物理路径
result = file;
try
{
//以不同格式保存图片
if(filetype.Trim().ToLower().CompareTo(".png") == )
{
oImage.Save(oFullName, System.Drawing.Imaging.ImageFormat.Png);
tImage.Save(tFullName, System.Drawing.Imaging.ImageFormat.Png);
}
else
{
oImage.Save(oFullName, System.Drawing.Imaging.ImageFormat.Jpeg);
tImage.Save(tFullName, System.Drawing.Imaging.ImageFormat.Jpeg);
} }
catch(Exception ex)
{
throw ex;
}
finally
{
//释放资源
oImage.Dispose();
g.Dispose();
tImage.Dispose(); }
return result;
} #region 上传图片
public string uploadDirect(System.Web.UI.HtmlControls.HtmlInputFile UploadFile)
{
string filetype = System.IO.Path.GetExtension(UploadFile.PostedFile.FileName);
string result = "";
//检查上传文件的格式是否有效
if(UploadFile.PostedFile.ContentType.ToLower().IndexOf("image") >= )
{
if(UploadFile.PostedFile.ContentType.ToLower().IndexOf("image") < )
{
result = "上传图片格式无效!";
return result;
} //生成原图
System.IO.Stream oStream = UploadFile.PostedFile.InputStream; System.Drawing.Image oImage = System.Drawing.Image.FromStream(oStream);
string file = DateTime.Now.ToShortDateString().Replace("-", "").Replace("/", "") + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + filetype;
string oFullName = System.Web.HttpContext.Current.Server.MapPath("../../UploadImg/") + file;//保存原图的物理路径
result = file;
try
{
//以不同格式保存图片
if(filetype.Trim().ToLower().CompareTo(".png") == )
{
oImage.Save(oFullName, System.Drawing.Imaging.ImageFormat.Png);
}
else
{
oImage.Save(oFullName, System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
catch(Exception ex)
{
//抛出异常
throw ex;
}
finally
{
//释放资源
oImage.Dispose(); }
}
else
{
string file = DateTime.Now.ToShortDateString().Replace("-", "").Replace("/", "") + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + filetype;
string oFullName = System.Web.HttpContext.Current.Server.MapPath("../../file/") + file;//保存原图的物理路径
result = file;
UploadFile.PostedFile.SaveAs(oFullName);
}
return result;
}
public string uploadArticle(System.Web.UI.HtmlControls.HtmlInputFile UploadFile)
{
string filetype = System.IO.Path.GetExtension(UploadFile.PostedFile.FileName);
string result = "";
//检查上传文件的格式是否有效
if(UploadFile.PostedFile.ContentType.ToLower().IndexOf("image") >= )
{
if(UploadFile.PostedFile.ContentType.ToLower().IndexOf("image") < )
{
result = "上传图片格式无效!";
return result;
} //生成原图
System.IO.Stream oStream = UploadFile.PostedFile.InputStream; System.Drawing.Image oImage = System.Drawing.Image.FromStream(oStream);
string file = DateTime.Now.ToShortDateString().Replace("-", "").Replace("/", "") + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + filetype;
string oFullName = System.Web.HttpContext.Current.Server.MapPath("../../UploadImg/") + file;//保存原图的物理路径
result = file;
try
{
//以不同格式保存图片
if(filetype.Trim().ToLower().CompareTo(".png") == )
{
oImage.Save(oFullName, System.Drawing.Imaging.ImageFormat.Png);
}
else
{
oImage.Save(oFullName, System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
catch(Exception ex)
{
throw ex;
}
finally
{
//释放资源
oImage.Dispose(); }
}
else
{
string file = DateTime.Now.ToShortDateString().Replace("-", "").Replace("/", "") + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + filetype;
string oFullName = System.Web.HttpContext.Current.Server.MapPath("File/") + file;//保存原图的物理路径
result = file;
UploadFile.PostedFile.SaveAs(oFullName);
}
return result;
} public string uploadDirectWeb(System.Web.UI.WebControls.FileUpload UploadFile)
{
string filetype = System.IO.Path.GetExtension(UploadFile.PostedFile.FileName);
string result = "";
//检查上传文件的格式是否有效
if(UploadFile.PostedFile.ContentType.ToLower().IndexOf("pdf") < )
{
if(UploadFile.PostedFile.ContentType.ToLower().IndexOf("image") < )
{
result = "上传图片格式无效!";
return result;
} //生成原图
System.IO.Stream oStream = UploadFile.PostedFile.InputStream; System.Drawing.Image oImage = System.Drawing.Image.FromStream(oStream);
string file = DateTime.Now.ToShortDateString().Replace("-", "").Replace("/", "") + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + filetype;
string oFullName = System.Web.HttpContext.Current.Server.MapPath("../../UploadImg/") + file;//保存原图的物理路径
result = file;
try
{
//以不同格式保存图片
if(filetype.Trim().ToLower().CompareTo(".png") == )
{
oImage.Save(oFullName, System.Drawing.Imaging.ImageFormat.Png);
}
else
{
oImage.Save(oFullName, System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
catch(Exception ex)
{
throw ex;
}
finally
{
//释放资源
oImage.Dispose(); }
}
else
{
string file = DateTime.Now.ToShortDateString().Replace("-", "").Replace("/", "") + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + ".pdf";
string oFullName = System.Web.HttpContext.Current.Server.MapPath("../../file/") + file;//保存原图的物理路径
result = file;
UploadFile.PostedFile.SaveAs(oFullName);
}
return result;
}
public string uploadPNG(System.Web.UI.HtmlControls.HtmlInputFile UploadFile)
{
string filetype = System.IO.Path.GetExtension(UploadFile.PostedFile.FileName);
string result = "";
//检查上传文件的格式是否有效
if(UploadFile.PostedFile.ContentType.ToLower().IndexOf("pdf") < )
{
if(UploadFile.PostedFile.ContentType.ToLower().IndexOf("image") < )
{
result = "上传图片格式无效!";
return result;
} //生成原图
System.IO.Stream oStream = UploadFile.PostedFile.InputStream; System.Drawing.Image oImage = System.Drawing.Image.FromStream(oStream);
string file = DateTime.Now.ToShortDateString().Replace("-", "").Replace("/", "") + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + filetype;
string oFullName = System.Web.HttpContext.Current.Server.MapPath("../../UploadImg/") + file;//保存原图的物理路径
result = file;
try
{
//以JPG格式保存图片
oImage.Save(oFullName, System.Drawing.Imaging.ImageFormat.Png);
}
catch(Exception ex)
{
throw ex;
}
finally
{
//释放资源
oImage.Dispose(); }
}
else
{
string file = DateTime.Now.ToShortDateString().Replace("-", "").Replace("/", "") + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + ".pdf";
string oFullName = System.Web.HttpContext.Current.Server.MapPath("../../file/") + file;//保存原图的物理路径
result = file;
UploadFile.PostedFile.SaveAs(oFullName);
}
return result;
}
public string uploadFlv(System.Web.UI.HtmlControls.HtmlInputFile UploadFile)
{
string result = "";
//检查上传文件的格式是否有效
string file = DateTime.Now.ToShortDateString().Replace("-", "").Replace("/", "") + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + ".flv";
string oFullName = System.Web.HttpContext.Current.Server.MapPath("../../file/") + file;//保存文件的物理路径
result = file;
UploadFile.PostedFile.SaveAs(oFullName);
return result;
}
public string uploadFile(System.Web.UI.HtmlControls.HtmlInputFile UploadFile)
{
string filetype = System.IO.Path.GetExtension(UploadFile.PostedFile.FileName);
string result = "";
string file = DateTime.Now.ToShortDateString().Replace("-", "").Replace("/", "") + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + filetype;
string oFullName = System.Web.HttpContext.Current.Server.MapPath("../../file/") + file;//保存文件的物理路径
result = file;
UploadFile.PostedFile.SaveAs(oFullName);
return result;
}
public string uploadProjectFile(System.Web.UI.HtmlControls.HtmlInputFile UploadFile, string filename)
{
string filetype = System.IO.Path.GetExtension(UploadFile.PostedFile.FileName);
string result = "";
string file = filename + "_" + DateTime.Now.ToShortDateString().Replace("-", "").Replace("/", "") + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + filetype;
string oFullName = System.Web.HttpContext.Current.Server.MapPath("../../file/") + file;//保存文件的物理路径
result = file;
UploadFile.PostedFile.SaveAs(oFullName);
return result;
} public string uploadAdvertisement(System.Web.UI.HtmlControls.HtmlInputFile UploadFile, string filename)
{
string filetype = System.IO.Path.GetExtension(UploadFile.PostedFile.FileName);
string result = "";
if(filetype.Trim().CompareTo(".flv") != )
{
result = "wrongformat";
}
else
{
string file = filename + filetype;
string oFullName = System.Web.HttpContext.Current.Server.MapPath("../../flash/") + file;//保存文件的物理路径
result = file;
UploadFile.PostedFile.SaveAs(oFullName);
}
return result;
}
#endregion }
}
【.NET】上传文件,生成缩略图的更多相关文章
- yii php 图片上传与生成缩略图
今天需要做图片上传与生成缩略图的功能,把代码进行记录如下: html 视图 ($pic_action_url = $this->createAbsoluteUrl('h ...
- tp3.2 自带的文件上传及生成缩略图功能
public function upload_file($file_name,$width,$height) { //检查图片尺寸是否合法 $image_size = getimagesize($_F ...
- spring boot:实现图片文件上传并生成缩略图(spring boot 2.3.1)
一,为什么要给图片生成缩略图? 1, 用户上传的原始图片如果太大,不能直接展示在网站页面上, 因为不但流费server的流量,而且用户打开时非常费时间, 所以要生成缩略图. 2,服务端管理图片要注意的 ...
- Office文件上传自动生成缩略图
来源:微信公众号CodeL 前不久产品经理提出一个X的需求,说上传office文件的时候需要将首页自动截图,用于显示文件列表的时候将文件第一页缩略图展示给用户.实现的方式有多种,这里给大家介绍一个简单 ...
- Office文件上传自动生成缩略图-C#开发
原文: http://www.knowsky.com/898407.html 上传office文件的时候需要将首页自动截图,用于显示文件列表的时候将文件第一页缩略图展示给用户.实现的方式有多种,这里给 ...
- webuploader 上传文件 生成链接下载文件
最近 在asp.net MVC 项目 需要实现一个Excel和 图片上传功能.之前有使用过SWFUpload 做过上传图片功能,在本次实现过程中,有人推荐WebUploader 上传组件,因此采用we ...
- CI自带的文件上传及生成缩略图
/* * 文件上传 * @param $upload_path 文件上传路径 * @param $formpic 表单name属性名称 */ private function doUpload($up ...
- Yii 图片FTP批量上传 并生成缩略图
图片批量上传,前台使用 uploadify.swf,这个就不介绍了.这里使用两个扩展,一个是FTP上传的扩展,还有一个是生成缩略图的扩展地址:http://www.yiiframework.com/e ...
- java 上传文件-生成文件首页缩略图 生成pdf 抓取图片
方法:1.文件转换成pdf(采用openoffice或者jacob) 2.抓取pdf首页图 第一步:采用jacob: a.下载jacob 注意区分32位,64位,否则不能用 将dll文件放在ja ...
- jquery php ajax多图片上传.上传进度,生成缩略图
本例用到其他2个php class.upload.php和 functions.php还有css和js以及img文件 下载地址为www.freejs.net/demo/91/down.zip 演示 J ...
随机推荐
- nginx整合tomcat集群并做session共享----测试案例
最近出于好奇心,研究了一下tomcat集群配置,并整合nginx,实现负载均衡,session共享,写篇记录,防止遗忘.---------菜鸡的自我修炼. 说明:博主采用一个web项目同时部署到两台t ...
- Dubbo源码学习--服务是如何引用的
ReferenceBean 跟服务引用一样,Dubbo的reference配置会被转成ReferenceBean类,ReferenceBean实现了InitializingBean接口,直接看afte ...
- TypeScript 中的 SOLID 原则
下面的文章解释了正确使用 TypeScrip的 SOLID原则. 原文地址:https://samueleresca.net/2016/08/solid-principles-using-typesc ...
- [翻译]Eureka一窥
什么是Eureka? Eureka是一个基于REST的服务,主要用在AWS云环境作为服务发现,负载均衡和失败转移.我们叫这个服务,Eureka服务. Eureka也有一个JAVA客户端组件, Eure ...
- [nodejs,expressjs,angularjs2] LOL英雄列表数据抓取及查询显示应用
新手练习,尝试使用angularjs2 [angularjs2 数据绑定,监听数据变化自动修改相应dom值,非常方便好用,但与传统js(jquery)的使用方法会很不同,Dom操作也不太习惯] 应用效 ...
- linux基础命令大全
编辑器 ed vi/vim (交互式) sed (非交互) vi/vim 的使用 1.命令模式 移动光标 方向键 hjkl H L M G 1G nG 复制行 yy nyy 粘贴 p 删除行 dd n ...
- mybatis-generator 代码自动生成工具(maven方式)
由于MyBatis属于一种半自动的ORM框架,所以主要的工作将是书写Mapping映射文件,但是由于手写映射文件很容易出错,mybatis-gennerator插件帮我们自动生成mybatis所需要的 ...
- PNG文件转png8
png8比普通png图片会小很多,所以在开发中为了是图片加载速度更快我们可以把Png图片都转成png8 首先添加 ImageProcessor 包 private byte[] ConvertTo ...
- 前端技术——WebFont与Sprite
一.WebFont web font是应用在web中的一种字体技术,在CSS中使用font-face定义新的字体. 我们在文档中显示的字体应该在系统中能找到才会正常显示,比如你在word中使用了黑体字 ...
- python3 介绍
一.历史 python的创始人为吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹打发时间,决心开发一个新的脚本解释程序,作为ABC语言的一种继 ...