热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

thinkphp改写的上传类与缩放,水印类

2019独角兽企业重金招聘Python工程师标准

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2009 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st 
// +----------------------------------------------------------------------
// $Id$/**+------------------------------------------------------------------------------* 文件上传类+------------------------------------------------------------------------------* @category   ORG* @package  ORG* @subpackage  Net* @author    liu21st * @version   $Id$+------------------------------------------------------------------------------*/
class UploadFile
{//类定义开始// 上传文件的最大值public $maxSize &#61; -1;// 是否支持多文件上传public $supportMulti &#61; true;// 允许上传的文件后缀//  留空不作后缀检查public $allowExts &#61; array();// 允许上传的文件类型// 留空不做检查public $allowTypes &#61; array();// 使用对上传图片进行缩略图处理public $thumb   &#61;  true;// 缩略图最大宽度public $thumbWidth&#61;400;// 缩略图最大高度public $thumbHeight&#61;400;// 缩略图前缀public $thumbPrefix   &#61;  &#39;thumb_&#39;;public $thumbSuffix  &#61;  &#39;,&#39;;// 缩略图保存路径public $thumbPath &#61; &#39;&#39;;// 缩略图文件名public $thumbFile        &#61;&#39;&#39;;// 是否移除原图public $thumbRemoveOrigin &#61;true;// 启用子目录保存文件public $autoSub   &#61;  false;// 子目录创建方式 可以使用hash datepublic $subType   &#61; &#39;date&#39;;public $dateFormat &#61; &#39;Ym&#39;;public $hashLevel &#61;  1; // hash的目录层次// 上传文件保存路径public $savePath &#61; &#39;&#39;;public $autoCheck &#61; true; // 是否自动检查附件// 存在同名是否覆盖public $uploadReplace &#61; false;// 上传文件命名规则// 例如可以是 time uniqid com_create_guid 等// 必须是一个无需任何参数的函数名 可以使用自定义函数public $saveRule &#61; &#39;uniqid&#39;;// 错误信息private $error &#61; &#39;&#39;;// 上传成功的文件信息private $uploadFileInfo ;/**&#43;----------------------------------------------------------* 架构函数&#43;----------------------------------------------------------* &#64;access public&#43;----------------------------------------------------------*/public function __construct($maxSize&#61;&#39;&#39;,$allowExts&#61;&#39;&#39;,$allowTypes&#61;&#39;&#39;,$savePath&#61;&#39;&#39;,$saveRule&#61;&#39;&#39;){if(!empty($maxSize) && is_numeric($maxSize)) {$this->maxSize &#61; $maxSize;}if(!empty($allowExts)) {if(is_array($allowExts)) {$this->allowExts &#61; array_map(&#39;strtolower&#39;,$allowExts);}else {$this->allowExts &#61; explode(&#39;,&#39;,strtolower($allowExts));}}if(!empty($allowTypes)) {if(is_array($allowTypes)) {$this->allowTypes &#61; array_map(&#39;strtolower&#39;,$allowTypes);}else {$this->allowTypes &#61; explode(&#39;,&#39;,strtolower($allowTypes));}}if(!empty($saveRule)) {$this->saveRule &#61; $saveRule;}$this->savePath .&#61; $savePath;}/**&#43;----------------------------------------------------------* 上传一个文件&#43;----------------------------------------------------------* &#64;access public&#43;----------------------------------------------------------* &#64;param mixed $name 数据* &#64;param string $value  数据表名&#43;----------------------------------------------------------* &#64;return string&#43;----------------------------------------------------------* &#64;throws ThinkExecption&#43;----------------------------------------------------------*/private function save(&$file){$filename &#61; $file[&#39;savepath&#39;].$file[&#39;savename&#39;];if(!$this->uploadReplace && is_file($filename)) {// 不覆盖同名文件$this->error    &#61;    &#39;文件已经存在&#xff01;&#39;.$filename;return false;}// 如果是图像文件 检测文件格式if( in_array(strtolower($file[&#39;extension&#39;]),array(&#39;gif&#39;,&#39;jpg&#39;,&#39;jpeg&#39;,&#39;bmp&#39;,&#39;png&#39;,&#39;swf&#39;)) && false &#61;&#61;&#61; getimagesize($file[&#39;tmp_name&#39;])) {$this->error &#61; &#39;非法图像文件&#39;;return false;}if(!move_uploaded_file($file[&#39;tmp_name&#39;],$filename)) {$this->error &#61; &#39;文件上传保存错误&#xff01;&#39;;return false;}if($this->thumb && in_array(strtolower($file[&#39;extension&#39;]),array(&#39;gif&#39;,&#39;jpg&#39;,&#39;jpeg&#39;,&#39;bmp&#39;,&#39;png&#39;))) {$image &#61;  getimagesize($filename);if(false !&#61;&#61; $image) {//是图像文件生成缩略图$thumbPath    &#61;  $this->thumbPath?$this->thumbPath:$file[&#39;savepath&#39;];$realFilename  &#61;  $this->autoSub?basename($file[&#39;savename&#39;]):$file[&#39;savename&#39;];$thumbname&#61;$this->thumbPrefix.substr($realFilename,0,strrpos($realFilename, &#39;.&#39;)).&#39;.&#39;.$file[&#39;extension&#39;];                    if(Image::thumb($filename,$thumbPath.$thumbname,&#39;&#39;,$this->thumbWidth,$this->thumbHeight,true)){$file[&#39;thumb&#39;]&#61;$thumbname;                   }                   if($this->thumbRemoveOrigin) {// 生成缩略图之后删除原图unlink($filename);}                                                }}return true;}/**&#43;----------------------------------------------------------* 上传所有文件&#43;----------------------------------------------------------* &#64;access public&#43;----------------------------------------------------------* &#64;param string $savePath  上传文件保存路径&#43;----------------------------------------------------------* &#64;return string&#43;----------------------------------------------------------* &#64;throws ThinkExecption&#43;----------------------------------------------------------*/public function upload($savePath &#61;&#39;&#39;){//如果不指定保存文件名&#xff0c;则由系统默认if(empty($savePath))$savePath &#61; $this->savePath;// 检查上传目录if(!is_dir($savePath)) {// 检查目录是否编码后的if(is_dir(base64_decode($savePath))) {$savePath    &#61;    base64_decode($savePath);}else{// 尝试创建目录if(!mkdir($savePath)){$this->error  &#61;  &#39;上传目录&#39;.$savePath.&#39;不存在&#39;;return false;}}}else {if(!is_writeable($savePath)) {$this->error  &#61;  &#39;上传目录&#39;.$savePath.&#39;不可写&#39;;return false;}}$fileInfo &#61; array();$isUpload   &#61; false;// 获取上传的文件信息// 对$_FILES数组信息处理$files     &#61;     $this->dealFiles($_FILES);foreach($files as $key &#61;> $file) {//过滤无效的上传if(!empty($file[&#39;name&#39;])) {//登记上传文件的扩展信息$file[&#39;key&#39;]          &#61;  $key;$file[&#39;extension&#39;]  &#61; $this->getExt($file[&#39;name&#39;]);$file[&#39;savepath&#39;]   &#61; $savePath;$file[&#39;savename&#39;]   &#61; $this->getSaveName($file);// 自动检查附件if($this->autoCheck) {if(!$this->check($file))return false;}//保存上传文件if(!$this->save($file)) return false;//上传成功后保存文件信息&#xff0c;供其他地方调用unset($file[&#39;tmp_name&#39;],$file[&#39;error&#39;]);$fileInfo[] &#61; $file;$isUpload   &#61; true;}}if($isUpload) {$this->uploadFileInfo &#61; $fileInfo;return true;}else {$this->error  &#61;  &#39;没有选择上传文件&#39;;return false;}}/**&#43;----------------------------------------------------------* 上传单个上传字段中的文件 支持多附件&#43;----------------------------------------------------------* &#64;access public&#43;----------------------------------------------------------* &#64;param array $file  上传文件信息* &#64;param string $savePath  上传文件保存路径&#43;----------------------------------------------------------* &#64;return string&#43;----------------------------------------------------------* &#64;throws ThinkExecption&#43;----------------------------------------------------------*/public function uploadOne($file,$savePath&#61;&#39;&#39;){//如果不指定保存文件名&#xff0c;则由系统默认if(empty($savePath))$savePath &#61; $this->savePath;// 检查上传目录if(!is_dir($savePath)) {// 尝试创建目录if(!mkdir($savePath)){$this->error  &#61;  &#39;上传目录&#39;.$savePath.&#39;不存在&#39;;return false;}}else {if(!is_writeable($savePath)) {$this->error  &#61;  &#39;上传目录&#39;.$savePath.&#39;不可写&#39;;return false;}}//过滤无效的上传if(!empty($file[&#39;name&#39;])) {$fileArray &#61; array();if(is_array($file[&#39;name&#39;])) {$keys &#61; array_keys($file);$count     &#61;     count($file[&#39;name&#39;]);for ($i&#61;0; $i<$count; $i&#43;&#43;) {foreach ($keys as $key)$fileArray[$i][$key] &#61; $file[$key][$i];}}else{$fileArray[] &#61;  $file;}$info &#61;  array();foreach ($fileArray as $key&#61;>$file){//登记上传文件的扩展信息$file[&#39;extension&#39;]  &#61; $this->getExt($file[&#39;name&#39;]);$file[&#39;savepath&#39;]   &#61; $savePath;$file[&#39;savename&#39;]   &#61; $this->getSaveName($file);// 自动检查附件if($this->autoCheck) {if(!$this->check($file))return false;}//保存上传文件if(!$this->save($file)) return false;unset($file[&#39;tmp_name&#39;],$file[&#39;error&#39;]);$info[] &#61; $file;$isUpload&#61;true;}if($isUpload) {$this->uploadFileInfo &#61; $info;return true;// 返回上传的文件信息}}else {$this->error  &#61;  &#39;没有选择上传文件&#39;;return false;}}/**&#43;----------------------------------------------------------* 转换上传文件数组变量为正确的方式&#43;----------------------------------------------------------* &#64;access private&#43;----------------------------------------------------------* &#64;param array $files  上传的文件变量&#43;----------------------------------------------------------* &#64;return array&#43;----------------------------------------------------------*/private function dealFiles($files) {$fileArray &#61; array();$n &#61; 0;foreach ($files as $file){if(is_array($file[&#39;name&#39;])) {$keys &#61; array_keys($file);$count     &#61;     count($file[&#39;name&#39;]);for ($i&#61;0; $i<$count; $i&#43;&#43;) {foreach ($keys as $key)$fileArray[$n][$key] &#61; $file[$key][$i];$n&#43;&#43;;}}else{$fileArray[$n] &#61; $file;$n&#43;&#43;;}}return $fileArray;}/**&#43;----------------------------------------------------------* 获取错误代码信息&#43;----------------------------------------------------------* &#64;access public&#43;----------------------------------------------------------* &#64;param string $errorNo  错误号码&#43;----------------------------------------------------------* &#64;return void&#43;----------------------------------------------------------* &#64;throws ThinkExecption&#43;----------------------------------------------------------*/protected function error($errorNo){switch($errorNo) {case 1:$this->error &#61; &#39;上传的文件超过了 php.ini 中 upload_max_filesize 选项限制的值&#39;;break;case 2:$this->error &#61; &#39;上传文件的大小超过了 HTML 表单中 MAX_FILE_SIZE 选项指定的值&#39;;break;case 3:$this->error &#61; &#39;文件只有部分被上传&#39;;break;case 4:$this->error &#61; &#39;没有文件被上传&#39;;break;case 6:$this->error &#61; &#39;找不到临时文件夹&#39;;break;case 7:$this->error &#61; &#39;文件写入失败&#39;;break;default:$this->error &#61; &#39;未知上传错误&#xff01;&#39;;}return ;}/**&#43;----------------------------------------------------------* 根据上传文件命名规则取得保存文件名&#43;----------------------------------------------------------* &#64;access private&#43;----------------------------------------------------------* &#64;param string $filename 数据&#43;----------------------------------------------------------* &#64;return string&#43;----------------------------------------------------------*/private function getSaveName($filename){$rule &#61; $this->saveRule;if(empty($rule)) {//没有定义命名规则&#xff0c;则保持文件名不变$saveName &#61; $filename[&#39;name&#39;];}else {if(function_exists($rule)) {//使用函数生成一个唯一文件标识号$saveName &#61; $rule().".".$filename[&#39;extension&#39;];}else {//使用给定的文件名作为标识号$saveName &#61; $rule.".".$filename[&#39;extension&#39;];}}if($this->autoSub) {// 使用子目录保存文件$filename[&#39;savename&#39;] &#61; $saveName;$saveName &#61; $this->getSubName($filename).&#39;/&#39;.$saveName;}return $saveName;}/**&#43;----------------------------------------------------------* 获取子目录的名称&#43;----------------------------------------------------------* &#64;access private&#43;----------------------------------------------------------* &#64;param array $file  上传的文件信息&#43;----------------------------------------------------------* &#64;return string&#43;----------------------------------------------------------*/private function getSubName($file){switch($this->subType) {case &#39;date&#39;:$dir   &#61;  date($this->dateFormat,time());break;case &#39;hash&#39;:default:$name &#61; md5($file[&#39;savename&#39;]);$dir   &#61;  &#39;&#39;;for($i&#61;0;$i<$this->hashLevel;$i&#43;&#43;) {$dir   .&#61;  $name{$i}.&#39;/&#39;;}break;}if(!is_dir($file[&#39;savepath&#39;].$dir)) {mkdir($file[&#39;savepath&#39;].$dir);}return $dir;}/**&#43;----------------------------------------------------------* 检查上传的文件&#43;----------------------------------------------------------* &#64;access private&#43;----------------------------------------------------------* &#64;param array $file 文件信息&#43;----------------------------------------------------------* &#64;return boolean&#43;----------------------------------------------------------*/private function check($file) {if($file[&#39;error&#39;]!&#61;&#61; 0) {//文件上传失败//捕获错误代码$this->error($file[&#39;error&#39;]);return false;}//文件上传成功&#xff0c;进行自定义规则检查//检查文件大小if(!$this->checkSize($file[&#39;size&#39;])) {$this->error &#61; &#39;上传文件大小不符&#xff01;&#39;;return false;}//检查文件Mime类型if(!$this->checkType($file[&#39;type&#39;])) {$this->error &#61; &#39;上传文件MIME类型不允许&#xff01;&#39;;return false;}//检查文件类型if(!$this->checkExt($file[&#39;extension&#39;])) {$this->error &#61;&#39;上传文件类型不允许&#39;;return false;}//检查是否合法上传if(!$this->checkUpload($file[&#39;tmp_name&#39;])) {$this->error &#61; &#39;非法上传文件&#xff01;&#39;;return false;}return true;}/**&#43;----------------------------------------------------------* 检查上传的文件类型是否合法&#43;----------------------------------------------------------* &#64;access private&#43;----------------------------------------------------------* &#64;param string $type 数据&#43;----------------------------------------------------------* &#64;return boolean&#43;----------------------------------------------------------*/private function checkType($type){if(!empty($this->allowTypes))return in_array(strtolower($type),$this->allowTypes);return true;}/**&#43;----------------------------------------------------------* 检查上传的文件后缀是否合法&#43;----------------------------------------------------------* &#64;access private&#43;----------------------------------------------------------* &#64;param string $ext 后缀名&#43;----------------------------------------------------------* &#64;return boolean&#43;----------------------------------------------------------*/private function checkExt($ext){if(!empty($this->allowExts))return in_array(strtolower($ext),$this->allowExts,true);return true;}/**&#43;----------------------------------------------------------* 检查文件大小是否合法&#43;----------------------------------------------------------* &#64;access private&#43;----------------------------------------------------------* &#64;param integer $size 数据&#43;----------------------------------------------------------* &#64;return boolean&#43;----------------------------------------------------------*/private function checkSize($size){return !($size > $this->maxSize) || (-1 &#61;&#61; $this->maxSize);}/**&#43;----------------------------------------------------------* 检查文件是否非法提交&#43;----------------------------------------------------------* &#64;access private&#43;----------------------------------------------------------* &#64;param string $filename 文件名&#43;----------------------------------------------------------* &#64;return boolean&#43;----------------------------------------------------------*/private function checkUpload($filename){return is_uploaded_file($filename);}/**&#43;----------------------------------------------------------* 取得上传文件的后缀&#43;----------------------------------------------------------* &#64;access private&#43;----------------------------------------------------------* &#64;param string $filename 文件名&#43;----------------------------------------------------------* &#64;return boolean&#43;----------------------------------------------------------*/private function getExt($filename){$pathinfo &#61; pathinfo($filename);return $pathinfo[&#39;extension&#39;];}/**&#43;----------------------------------------------------------* 取得上传文件的信息&#43;----------------------------------------------------------* &#64;access public&#43;----------------------------------------------------------* &#64;return array&#43;----------------------------------------------------------*/public function getUploadFileInfo(){return $this->uploadFileInfo;}/**&#43;----------------------------------------------------------* 取得最后一次错误信息&#43;----------------------------------------------------------* &#64;access public&#43;----------------------------------------------------------* &#64;return string&#43;----------------------------------------------------------*/public function getErrorMsg(){return $this->error;}}//类定义结束
?>// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// &#43;----------------------------------------------------------------------
// | Copyright (c) 2009 http://thinkphp.cn All rights reserved.
// &#43;----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// &#43;----------------------------------------------------------------------
// | Author: liu21st 
// &#43;----------------------------------------------------------------------
// $Id$/**&#43;------------------------------------------------------------------------------* 图像操作类库&#43;------------------------------------------------------------------------------* &#64;category   ORG* &#64;package  ORG* &#64;subpackage  Util* &#64;author    liu21st * &#64;version   $Id$&#43;------------------------------------------------------------------------------*/
class Image{//类定义开始/**&#43;----------------------------------------------------------* 取得图像信息*&#43;----------------------------------------------------------* &#64;static* &#64;access public&#43;----------------------------------------------------------* &#64;param string $image 图像文件名&#43;----------------------------------------------------------* &#64;return mixed&#43;----------------------------------------------------------*/static function getImageInfo($img) {$imageInfo &#61; getimagesize($img);if ($imageInfo !&#61;&#61; false) {$imageType &#61; strtolower(substr(image_type_to_extension($imageInfo[2]), 1));$imageSize &#61; filesize($img);$info &#61; array("width" &#61;> $imageInfo[0],"height" &#61;> $imageInfo[1],"type" &#61;> $imageType,"size" &#61;> $imageSize,"mime" &#61;> $imageInfo[&#39;mime&#39;]);return $info;} else {return false;}}/**&#43;----------------------------------------------------------* 为图片添加水印&#43;----------------------------------------------------------* &#64;static public&#43;----------------------------------------------------------* &#64;param string $source 原文件名* &#64;param string $water  水印图片* &#64;param string $$savename  添加水印后的图片名* &#64;param string $alpha  水印的透明度&#43;----------------------------------------------------------* &#64;return string&#43;----------------------------------------------------------* &#64;throws ThinkExecption&#43;----------------------------------------------------------*/static public function water($source, $water, $savename&#61;null, $alpha&#61;80) {//检查文件是否存在if (!file_exists($source) || !file_exists($water))return false;//图片信息$sInfo &#61; self::getImageInfo($source);$wInfo &#61; self::getImageInfo($water);      //如果图片小于水印图片&#xff0c;不生成图片if ($sInfo["width"] < $wInfo["width"] || $sInfo[&#39;height&#39;] < $wInfo[&#39;height&#39;])return false;//建立图像$sCreateFun &#61; "imagecreatefrom" . $sInfo[&#39;type&#39;];$sImage &#61; $sCreateFun($source);$wCreateFun &#61; "imagecreatefrom" . $wInfo[&#39;type&#39;];$wImage &#61; $wCreateFun($water);//设定图像的混色模式imagealphablending($wImage, true);//图像位置,默认为右下角右对齐$posY &#61; $sInfo["height"] - $wInfo["height"];$posX &#61; $sInfo["width"] - $wInfo["width"];//生成混合图像imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[&#39;width&#39;], $wInfo[&#39;height&#39;], $alpha);//输出图像$ImageFun &#61; &#39;Image&#39; . $sInfo[&#39;type&#39;];//如果没有给出保存文件名&#xff0c;默认为原图像名if (!$savename) {$savename &#61; $source;&#64;unlink($source);}//保存图像$ImageFun($sImage, $savename);imagedestroy($sImage);return true;}/**&#43;----------------------------------------------------------* 生成缩略图&#43;----------------------------------------------------------* &#64;static* &#64;access public&#43;----------------------------------------------------------* &#64;param string $image  原图* &#64;param string $type 图像格式* &#64;param string $thumbname 缩略图文件名* &#64;param string $maxWidth  宽度* &#64;param string $maxHeight  高度* &#64;param string $position 缩略图保存目录* &#64;param boolean $interlace 启用隔行扫描&#43;----------------------------------------------------------* &#64;return void&#43;----------------------------------------------------------*/static function thumb($image, $thumbname, $type&#61;&#39;&#39;, $maxWidth&#61;200, $maxHeight&#61;50, $interlace&#61;true) {// 获取原图信息$info &#61; Image::getImageInfo($image);if ($info !&#61;&#61; false) {$srcWidth &#61; $info[&#39;width&#39;];$srcHeight &#61; $info[&#39;height&#39;];$type &#61; empty($type) ? $info[&#39;type&#39;] : $type;$type &#61; strtolower($type);$interlace &#61; $interlace ? 1 : 0;unset($info);$scale &#61; min($maxWidth / $srcWidth, $maxHeight / $srcHeight); // 计算缩放比例if ($scale >&#61; 1) {// 超过原图大小不再缩略$width &#61; $srcWidth;$height &#61; $srcHeight;} else {// 缩略图尺寸$width &#61; (int) ($srcWidth * $scale);$height &#61; (int) ($srcHeight * $scale);}// 载入原图$createFun &#61; &#39;ImageCreateFrom&#39; . ($type &#61;&#61; &#39;jpg&#39; ? &#39;jpeg&#39; : $type);$srcImg &#61; $createFun($image);//创建缩略图if ($type !&#61; &#39;gif&#39; && function_exists(&#39;imagecreatetruecolor&#39;))$thumbImg &#61; imagecreatetruecolor($width, $height);else$thumbImg &#61; imagecreate($width, $height);// 复制图片if (function_exists("ImageCopyResampled"))imagecopyresampled($thumbImg, $srcImg, 0, 0, 0, 0, $width, $height, $srcWidth, $srcHeight);elseimagecopyresized($thumbImg, $srcImg, 0, 0, 0, 0, $width, $height, $srcWidth, $srcHeight);if (&#39;gif&#39; &#61;&#61; $type || &#39;png&#39; &#61;&#61; $type) {//imagealphablending($thumbImg, false);//取消默认的混色模式//imagesavealpha($thumbImg,true);//设定保存完整的 alpha 通道信息$background_color &#61; imagecolorallocate($thumbImg, 0, 255, 0);  //  指派一个绿色imagecolortransparent($thumbImg, $background_color);  //  设置为透明色&#xff0c;若注释掉该行则输出绿色的图}// 对jpeg图形设置隔行扫描if (&#39;jpg&#39; &#61;&#61; $type || &#39;jpeg&#39; &#61;&#61; $type)imageinterlace($thumbImg, $interlace);//$gray&#61;ImageColorAllocate($thumbImg,255,0,0);//ImageString($thumbImg,2,5,5,"ThinkPHP",$gray);// 生成图片$imageFun &#61; &#39;image&#39; . ($type &#61;&#61; &#39;jpg&#39; ? &#39;jpeg&#39; : $type);$imageFun($thumbImg, $thumbname);imagedestroy($thumbImg);imagedestroy($srcImg);return $thumbname;}return false;}}//类定义结束
?>测试文件
header("Content-type:text/html;charset&#61;utf-8");
require  "UploadFile.class.php";
require  "Image.class.php";
$upload&#61;new UploadFile();
if(!$upload->uploadOne($_FILES[&#39;name&#39;],ROOT.&#39;upload/&#39;)){$upload->getErrorMsg();
}else{$list&#61;$upload->getUploadFileInfo();$info&#61;array();foreach ($list as $val){$info&#61;$val;}   $water&#61;ROOT.&#39;data/logo.png&#39;; $source&#61;$info[&#39;savepath&#39;].$info[&#39;thumb&#39;];$savename&#61;&#39;water&#39;.$info[&#39;savename&#39;];if(Image::water($source, $water)){}var_dump($info);  
}?>



转:https://my.oschina.net/u/998304/blog/226593



推荐阅读
  • mac php错误日志配置方法及错误级别修改
    本文介绍了在mac环境下配置php错误日志的方法,包括修改php.ini文件和httpd.conf文件的操作步骤。同时还介绍了如何修改错误级别,以及相应的错误级别参考链接。 ... [详细]
  • 如何实现织梦DedeCms全站伪静态
    本文介绍了如何通过修改织梦DedeCms源代码来实现全站伪静态,以提高管理和SEO效果。全站伪静态可以避免重复URL的问题,同时通过使用mod_rewrite伪静态模块和.htaccess正则表达式,可以更好地适应搜索引擎的需求。文章还提到了一些相关的技术和工具,如Ubuntu、qt编程、tomcat端口、爬虫、php request根目录等。 ... [详细]
  • 一、Hadoop来历Hadoop的思想来源于Google在做搜索引擎的时候出现一个很大的问题就是这么多网页我如何才能以最快的速度来搜索到,由于这个问题Google发明 ... [详细]
  • Android中高级面试必知必会,积累总结
    本文介绍了Android中高级面试的必知必会内容,并总结了相关经验。文章指出,如今的Android市场对开发人员的要求更高,需要更专业的人才。同时,文章还给出了针对Android岗位的职责和要求,并提供了简历突出的建议。 ... [详细]
  • 一句话解决高并发的核心原则
    本文介绍了解决高并发的核心原则,即将用户访问请求尽量往前推,避免访问CDN、静态服务器、动态服务器、数据库和存储,从而实现高性能、高并发、高可扩展的网站架构。同时提到了Google的成功案例,以及适用于千万级别PV站和亿级PV网站的架构层次。 ... [详细]
  • 在Docker中,将主机目录挂载到容器中作为volume使用时,常常会遇到文件权限问题。这是因为容器内外的UID不同所导致的。本文介绍了解决这个问题的方法,包括使用gosu和suexec工具以及在Dockerfile中配置volume的权限。通过这些方法,可以避免在使用Docker时出现无写权限的情况。 ... [详细]
  • 本文讨论了Alink回归预测的不完善问题,指出目前主要针对Python做案例,对其他语言支持不足。同时介绍了pom.xml文件的基本结构和使用方法,以及Maven的相关知识。最后,对Alink回归预测的未来发展提出了期待。 ... [详细]
  • 1,关于死锁的理解死锁,我们可以简单的理解为是两个线程同时使用同一资源,两个线程又得不到相应的资源而造成永无相互等待的情况。 2,模拟死锁背景介绍:我们创建一个朋友 ... [详细]
  • 也就是|小窗_卷积的特征提取与参数计算
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了卷积的特征提取与参数计算相关的知识,希望对你有一定的参考价值。Dense和Conv2D根本区别在于,Den ... [详细]
  • 本文介绍了Android 7的学习笔记总结,包括最新的移动架构视频、大厂安卓面试真题和项目实战源码讲义。同时还分享了开源的完整内容,并提醒读者在使用FileProvider适配时要注意不同模块的AndroidManfiest.xml中配置的xml文件名必须不同,否则会出现问题。 ... [详细]
  • CentOS 6.5安装VMware Tools及共享文件夹显示问题解决方法
    本文介绍了在CentOS 6.5上安装VMware Tools及解决共享文件夹显示问题的方法。包括清空CD/DVD使用的ISO镜像文件、创建挂载目录、改变光驱设备的读写权限等步骤。最后给出了拷贝解压VMware Tools的操作。 ... [详细]
  • 如何提高PHP编程技能及推荐高级教程
    本文介绍了如何提高PHP编程技能的方法,推荐了一些高级教程。学习任何一种编程语言都需要长期的坚持和不懈的努力,本文提醒读者要有足够的耐心和时间投入。通过实践操作学习,可以更好地理解和掌握PHP语言的特异性,特别是单引号和双引号的用法。同时,本文也指出了只走马观花看整体而不深入学习的学习方式无法真正掌握这门语言,建议读者要从整体来考虑局部,培养大局观。最后,本文提醒读者完成一个像模像样的网站需要付出更多的努力和实践。 ... [详细]
  • GreenDAO快速入门
    前言之前在自己做项目的时候,用到了GreenDAO数据库,其实对于数据库辅助工具库从OrmLite,到litePal再到GreenDAO,总是在不停的切换,但是没有真正去了解他们的 ... [详细]
  • Activiti7流程定义开发笔记
    本文介绍了Activiti7流程定义的开发笔记,包括流程定义的概念、使用activiti-explorer和activiti-eclipse-designer进行建模的方式,以及生成流程图的方法。还介绍了流程定义部署的概念和步骤,包括将bpmn和png文件添加部署到activiti数据库中的方法,以及使用ZIP包进行部署的方式。同时还提到了activiti.cfg.xml文件的作用。 ... [详细]
  • Android日历提醒软件开源项目分享及使用教程
    本文介绍了一款名为Android日历提醒软件的开源项目,作者分享了该项目的代码和使用教程,并提供了GitHub项目地址。文章详细介绍了该软件的主界面风格、日程信息的分类查看功能,以及添加日程提醒和查看详情的界面。同时,作者还提醒了读者在使用过程中可能遇到的Android6.0权限问题,并提供了解决方法。 ... [详细]
author-avatar
D调肥仔
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有