代码如下 | 复制代码 |
<?php /*---------------------------------------------------------------------------------- * *---------------------------------------------------------------------------------- */ class image_up{ //定义基本参数 private $uptype=array('image/jpg','image/jpeg','image/png','image/pjpeg','image/gif','image/bmp','image/x-png'); //上传文件类型 private $max_file_size=102400; //上传大小限制(单位:KB) private $destination_folder="up/"; //上传文件路径 private $watermark=1; //是否附加水印 private $watertype=1; //水印类型(1为文字,2为图片) private $waterposition=1; //水印位置(1为左下角,2为右下角,3为左上角,4为右上角,5为居中); private $waterstring=null; //水印字符串 private $waterimg=null; //水印图片 private $imgpreview=1; //是否生成预览图(1为生成,其他为不生成); private $imgpreviewsize=1; //预览图比例,0为按固定宽和高显示,其他为比例显示 private $imgwidth=200; //预览图固定宽度 private $imgheight=200; //预览图固定高度 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ private $imgthu=1; //是否生成且保存略缩图,1为生成,0为不生成 private $imgthu_folder=null; //略缩图保存路径,默认与文件路径一致 private $imgthu_fixed=0; //略缩图是否使用固定宽高,1为使用,0为灵活变动 private $imgthu_width=200; //略缩图宽度 private $imgthu_height=200; //略缩图高度 private $imgthu_name=null; //略缩图名称 //****************************************************************************************************************** private $inputname="upfile"; //文件上传框名称 //****************************************************************************************************************** private $img_preview_display; //图片预览图显示 //****************************************************************************************************************** //文件上传相关信息,1为文件不存在,2为类型不符合,3为超出大小限制,4为上传失败,0为上传成功 private $file_up_info=null; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //可在外部获取上传文件基本信息 private $file_name; //客服端文件的原名称 private $file_type; //文件的MIME类型 private $file_size; //已上传文件的大小,单位/字节 private $file_tmp_name; //储存的临时文件名 private $file_error; //该文件上传相关错误代码 private $img_size; //取得图片的长宽 switch($imginfo[2]) switch($this->watertype) switch ($imginfo[2]) |
php图片上传类,支持加水印,生成略缩图
时间: 2024-07-30 23:38:36
php图片上传类,支持加水印,生成略缩图的相关文章
PHP之图片上传类实例代码(加了缩略图)
有缩略图功能 但是 感觉不全面,而且有点问题,继续学习,将来以后修改下 <form action="<?php $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data" method="post" ><input type="text" name="name" /><input type="file&q
php 图片上传类代码
php 图片上传类代码,功能也比较全,大家根据需要选择. 先来个简单的: <? //http://www.jzxue.com class upLoad{ public $length; //限定文件大小 public $file; //判断此类是用于图片上传还是文件上传 public $fileName; //文件名 public $fileTemp; //上传临时文件 public $fileSize; //上传文件大小 public $error; //上传文件是否有错,php4没有 pub
PHP实现多图片上传类实例
这篇文章主要介绍了PHP实现多图片上传类实例,该类文件注释详细功能实用且具有一定的扩展性,需要的朋友可以参考下 本文所述为一个实用的PHP多图片文件上传类,其支持gif.jpg.jpeg.pjpeg.png格式的多图片上传功能,类中还可限制图片类型.上传图片的大小.设置上传目录.一些提交判断等功能.此外该类并不局限于图片的上传,也可以上传TXT/RAR等文件类型,只是需要对代码进行一下修改,感兴趣的读者可以自己尝试一下. php多图片上传类完整功能代码如下: class more_file_
aspnet-asp.netMVC怎么给上传的照片加水印
问题描述 asp.netMVC怎么给上传的照片加水印 上传的照片前台是 图片: 保存 解决方案 http://blog.tallan.com/2011/02/04/watermarking-images-using-the-razor-webimage-helper/ http://saeidp.wordpress.com/2010/10/25/mvc-watermarking-an-image/ 解决方案二: 神马代码也没看到... 解决方案三: http://stackoverflow.co
html5 图片上传,支持图片预览、压缩、及进度显示,兼容IE6+及标准浏览器
原文:html5 图片上传,支持图片预览.压缩.及进度显示,兼容IE6+及标准浏览器 以前写过上传组件,见 打造 html5 文件上传组件,实现进度显示及拖拽上传,兼容IE6+及其它标准浏览器,对付一般的上传没有问题,不过如果是上传图片,且需要预览的话,就力有不逮了,趁着闲暇时间,给上传组件添加了单独的图片上传UI,支持图片预览和缩放(通过调整图片的大小以实现图片压缩). 上传组件特点 轻量级,不依赖任何JS库,核心代码(Q.Uploader.js)仅约700行,min版本加起来不到12KB 纯
PHP实现多图片上传类实例_php技巧
本文所述为一个实用的PHP多图片文件上传类,其支持gif.jpg.jpeg.pjpeg.png格式的多图片上传功能,类中还可限制图片类型.上传图片的大小.设置上传目录.一些提交判断等功能.此外该类并不局限于图片的上传,也可以上传TXT/RAR等文件类型,只是需要对代码进行一下修改,感兴趣的读者可以自己尝试一下. php多图片上传类完整功能代码如下: <?php class more_file_upload{ const FILE_PATH = '/uploadfile/'; //默认文件上传的目
php版阿里云OSS图片上传类详解_php技巧
本文实例讲述了php版阿里云OSS图片上传类.分享给大家供大家参考,具体如下: 1.阿里云基本函数 /** * 把本地变量的内容到文件 * 简单上传,上传指定变量的内存值作为object的内容 */ public function putObject($imgPath,$object) { $content = file_get_contents($imgPath); // 把当前文件的内容获取到传入文件中 $options = array(); try { $this->ossClient->
PHP手写的图片上传类
一个新手写的 PHP 图片上传类,基本的功能已经满足,可以返回客户端文件名,文件大小,临时文件夹路径,允许上传的文件类型,文件后缀,新路径,新文件名,图片宽度,图片高度,自定义上传成功消息,显示上传的状态..是否上传成功的信息等等,外加构造函数,对于新手学习来说,已经足够了,值得研究学习.. 在使用时,和其它PHP类一样,先要进行初始化对象,在前台调用函数方法即可,这里不再详细说明,这个类的研究价值主要在于代码的规范与实用,并没有大量繁琐的代码,都是一些简单的上传函数整合成的一个PHP图片上传类
php封装的单文件(图片)上传类完整实例_php技巧
本文实例讲述了php封装的单文件(图片)上传类.分享给大家供大家参考,具体如下: <?php //封装php中的单文件(图片)上传类 /* //参数1:$file 文件数组 5个属性值 name,type,size,tmp,error //参数2:文件保存的路径$path //参数3:文件上传允许的类型 $allow数组 $allow=array('image/jpeg','image/jpg','image/png','image/gif') //参数4: 允许文件上传的最大大小 $size