当前位置: 首页>>代码示例>>PHP>>正文


PHP Image::water方法代码示例

本文整理汇总了PHP中Image::water方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::water方法的具体用法?PHP Image::water怎么用?PHP Image::water使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Image的用法示例。


在下文中一共展示了Image::water方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: hd_uploadify

 /**
  * Uploadify上传文件处理
  */
 public function hd_uploadify()
 {
     $uploadModel = M('upload');
     //上传文件类型
     if (isset($_POST['type'])) {
         $type = str_replace('*.', '', $_POST['type']);
         $type = explode(';', $type);
     } else {
         $type = array();
     }
     $size = Q('size') ? Q('size') : C('allow_size');
     $upload = new Upload(Q('upload_dir'), $type, $size);
     $file = $upload->upload();
     if (!empty($file)) {
         $file = $file[0];
         $file['uid'] = $_SESSION['user']['uid'];
         //图片加水印
         if ($file['image'] && Q('water')) {
             $img = new Image();
             $img->water($file['path']);
         }
         //写入upload表
         $uploadModel->add($file);
         $data = $file;
         $data['status'] = 1;
     } else {
         $data['status'] = 0;
         $data['message'] = $upload->error;
     }
     echo json_encode($data);
     exit;
 }
开发者ID:suhanyujie,项目名称:spider,代码行数:35,代码来源:ContentUploadController.class.php

示例2: hd_uploadify

 /**
  * Uploadify上传文件处理
  */
 public function hd_uploadify()
 {
     $uploadModel = M('upload');
     $size = Q('size') ? Q('size') : C('allow_size');
     $upload = new Upload(Q('post.upload_dir'), array(), $size);
     $file = $upload->upload();
     if (!empty($file)) {
         $file = $file[0];
         $file['uid'] = session('uid');
         //图片加水印
         if ($file['image'] && Q('water')) {
             $img = new Image();
             $img->water($file['path']);
         }
         //写入upload表
         $uploadModel->add($file);
         $data = $file;
         $data['status'] = 1;
         $data['isimage'] = $file['image'] ? 1 : 0;
     } else {
         $data['status'] = 0;
         $data['message'] = $upload->error;
     }
     echo json_encode($data);
     exit;
 }
开发者ID:lililishuang,项目名称:hdcms,代码行数:29,代码来源:ContentUploadController.class.php

示例3: do_it

 function do_it($image, $ImgWaterPath, $ImgWaterPos, $ImageWaterAlpha, $i)
 {
     echo "正在处理第" . $i . "张图片:" . $image . "<br/>";
     flush();
     ob_flush();
     Image::water($image, $ImgWaterPath, $ImgWaterPos, '', $ImageWaterAlpha);
 }
开发者ID:dalinhuang,项目名称:concourse,代码行数:7,代码来源:WaterAction.class.php

示例4: down_img

 public function down_img($url, $mid = 'video')
 {
     $chr = strrchr($url, '.');
     $imgUrl = uniqid();
     $imgPath = $mid . '/' . date(C('upload_style'), time()) . '/';
     $imgPath_s = './' . C('upload_path') . '-s/' . $imgPath;
     $filename = './' . C('upload_path') . '/' . $imgPath . $imgUrl . $chr;
     $get_file = get_collect_file($url);
     if ($get_file) {
         write_file($filename, $get_file);
         //是否添加水印
         if (C('upload_water')) {
             import('ORG.Util.Image');
             Image::water($filename, C('upload_water_img'), '', C('upload_water_pct'), C('upload_water_pos'));
         }
         //是否生成缩略图
         if (C('upload_thumb')) {
             mkdirss($imgPath_s);
             import('ORG.Util.Image');
             Image::thumb($filename, $imgPath_s . $imgUrl . $chr, '', C('upload_thumb_w'), C('upload_thumb_h'), true);
         }
         //是否上传远程
         if (C('upload_ftp')) {
             $this->ftp_upload($imgPath . $imgUrl . $chr);
         }
         return $imgPath . $imgUrl . $chr;
     } else {
         return $url;
     }
 }
开发者ID:skygunner,项目名称:ekucms,代码行数:30,代码来源:AdminAction.class.php

示例5: upload

 public function upload()
 {
     echo '<div style="font-size:12px; height:30px; line-height:30px">';
     $uppath = './' . C('upload_path') . '/';
     $uppath_s = './' . C('upload_path') . '-s/';
     $mid = trim($_POST['mid']);
     $fileback = !empty($_POST['fileback']) ? trim($_POST['fileback']) : 'picurl';
     if ($mid) {
         $uppath .= $mid . '/';
         $uppath_s .= $mid . '/';
         $backpath = $mid . '/';
     }
     import("ORG.Net.UploadFile");
     $up = new UploadFile();
     //$up->maxSize = 3292200;
     $up->savePath = $uppath;
     $up->saveRule = uniqid;
     $up->uploadReplace = true;
     $up->allowExts = explode(',', C('cms_exts'));
     $up->autoSub = true;
     $up->subType = date;
     $up->dateFormat = C('upload_style');
     if (!$up->upload()) {
         $error = $up->getErrorMsg();
         if ($error == '上传文件类型不允许') {
             $error .= ',可上传<font color=red>' . C('cms_exts') . '</font>';
         }
         exit($error . ' [<a href="?s=Admin/Upload/Show/mid/' . $mid . '/fileback/' . $fileback . '">重新上传</a>]');
         //dump($up->getErrorMsg());
     }
     $uploadList = $up->getUploadFileInfo();
     //是否添加水印
     if (C('upload_water')) {
         import("ORG.Util.Image");
         Image::water($uppath . $uploadList[0]['savename'], C('upload_water_img'), '', C('upload_water_pct'), C('upload_water_pos'));
     }
     //是否生成缩略图
     if (C('upload_thumb')) {
         $thumbdir = substr($uploadList[0]['savename'], 0, strrpos($uploadList[0]['savename'], '/'));
         mkdirss($uppath_s . $thumbdir);
         import("ORG.Util.Image");
         Image::thumb($uppath . $uploadList[0]['savename'], $uppath_s . $uploadList[0]['savename'], '', C('upload_thumb_w'), C('upload_thumb_h'), true);
     }
     //是否远程图片
     if (C('upload_ftp')) {
         $img = D('Down');
         $img->ftp_upload($backpath . $uploadList[0]['savename']);
     }
     echo "<script type='text/javascript'>parent.document.getElementById('" . $fileback . "').value='" . $backpath . $uploadList[0]['savename'] . "';</script>";
     echo '文件<a href="' . $uppath . $uploadList[0]['savename'] . '" target="_blank"><font color=red>' . $uploadList[0]['savename'] . '</font></a>上传成功 [<a href="?s=Admin/Upload/Show/mid/' . $mid . '/fileback/' . $fileback . '">重新上传</a>]';
     echo '</div>';
 }
开发者ID:singhvicky,项目名称:pintrest,代码行数:52,代码来源:UploadAction.class.php

示例6: upload

 public function upload()
 {
     $upload = new \Think\Upload();
     //  实例化上传类
     $upload->savePath = './Uploads/';
     $info = $upload->upload($_FILES);
     if ($info) {
         import('Common/Org/Util/Image');
         $img = new \Image();
         $img->water($info['upfile']['savepath'] . $info['upfile']['savename']);
         echo json_encode(array('url' => ltrim($info['upfile']['savepath'] . $info['upfile']['savename'], '.'), 'title' => htmlspecialchars($_POST['pictitle'], ENT_QUOTES), 'original' => $info['upfile']['name'], 'state' => 'SUCCESS'));
     } else {
         echo json_encode(array('state' => $upload->getError()));
     }
 }
开发者ID:xupp,项目名称:ThinkPHP,代码行数:15,代码来源:SinglepageController.class.php

示例7: _upload

 protected function _upload()
 {
     import('@.ORG.UploadFile');
     //导入上传类
     $upload = new UploadFile();
     //设置上传文件大小
     $upload->maxSize = 3292200;
     //设置上传文件类型
     $upload->allowExts = explode(',', 'jpg,gif,png,jpeg');
     //设置附件上传目录
     $upload->savePath = './Uploads/';
     //设置需要生成缩略图,仅对图像文件有效
     $upload->thumb = true;
     // 设置引用图片类库包路径
     $upload->imageClassPath = '@.ORG.Image';
     //设置需要生成缩略图的文件后缀
     $upload->thumbPrefix = 'm_,s_';
     //生产2张缩略图
     //设置缩略图最大宽度
     $upload->thumbMaxWidth = '400,100';
     //设置缩略图最大高度
     $upload->thumbMaxHeight = '400,100';
     //设置上传文件规则
     $upload->saveRule = 'uniqid';
     //删除原图
     $upload->thumbRemoveOrigin = true;
     if (!$upload->upload()) {
         //捕获上传异常
         $this->error($upload->getErrorMsg());
     } else {
         //取得成功上传的文件信息
         $uploadList = $upload->getUploadFileInfo();
         import('@.ORG.Image');
         //给m_缩略图添加水印, Image::water('原文件名','水印图片地址')
         Image::water($uploadList[0]['savepath'] . 'm_' . $uploadList[0]['savename'], APP_PATH . 'Tpl/Public/Images/logo.png');
         $_POST['image'] = $uploadList[0]['savename'];
     }
     $model = M('Photo');
     //保存当前数据对象
     $data['image'] = $_POST['image'];
     $data['create_time'] = NOW_TIME;
     $list = $model->add($data);
     if ($list !== false) {
         $this->success('上传图片成功!');
     } else {
         $this->error('上传图片失败!');
     }
 }
开发者ID:highestgoodlikewater,项目名称:examples,代码行数:48,代码来源:IndexAction.class.php

示例8: upload

 public function upload()
 {
     import('ORG.Net.UploadFile');
     $upload = new UploadFile();
     $upload->autoSub = true;
     $upload->subType = 'date';
     $upload->dateFormat = 'Ym';
     if ($upload->upload('./Uploads/')) {
         $info = $upload->getUploadFileInfo();
         // import('ORG.Util.Image');
         // Image::water('./Uploads/' . $info[0]['savename'], './Data/fff.png');
         import('Class.Image', APP_PATH);
         Image::water('./Uploads/' . $info[0]['savename'], './Data/fff.png');
         echo json_encode(array('url' => $info[0]['savename'], 'title' => htmlspecialchars($POST['pictitle'], ENT_QUOTES), 'original' => $info[0]['name'], 'state' => 'SUCCESS'));
     } else {
         echo json_encode(array('state' => $upload->getErrorMsg()));
     }
 }
开发者ID:plsxysam,项目名称:blog_ThinkPHP,代码行数:18,代码来源:BlogAction.class.php

示例9: index

 public function index()
 {
     import('ORG.Net.UploadFile');
     $upload = new UploadFile();
     $upload->autoSub = true;
     $upload->subType = 'date';
     $upload->dateFormat = 'Ym';
     $CONFIG = json_decode(preg_replace("/\\/\\*[\\s\\S]+?\\*\\//", "", file_get_contents(CONF_PATH . "config.json")), true);
     $action = htmlspecialchars($_GET['action']);
     switch ($action) {
         case 'config':
             $result = json_encode($CONFIG);
             break;
             /* 上传图片 */
         /* 上传图片 */
         case 'uploadimage':
             if ($upload->upload('./Uploads/')) {
                 $info = $upload->getUploadFileInfo();
                 //引入外部的图像类处理水印
                 import('Class.Image', APP_PATH);
                 Image::water('./Uploads/' . $info[0]['savename']);
                 echo json_encode(array('url' => __ROOT__ . '/Uploads/' . $info[0]['savename'], 'original' => $info[0]['name'], 'state' => 'SUCCESS'));
             } else {
                 echo json_encode(array('state' => $upload->getErrorMsg()));
             }
             break;
         default:
             $result = json_encode(array('state' => '请求地址出错'));
             break;
     }
     /* 输出结果 */
     if (isset($_GET["callback"])) {
         if (preg_match("/^[\\w_]+\$/", $_GET["callback"])) {
             echo htmlspecialchars($_GET["callback"]) . '(' . $result . ')';
         } else {
             echo json_encode(array('state' => 'callback参数不合法'));
         }
     } else {
         echo $result;
     }
 }
开发者ID:thinksley,项目名称:movie,代码行数:41,代码来源:UeditorAction.class.php

示例10: uploads

 /**
  * 多文件上传
  *
  * @param boolean $thumb [description]
  * @return [type]         [description]
  */
 public static function uploads($params = false)
 {
     $conf = Config::get('', 'base');
     $params['thumbSize'] = array(400, 400);
     Yii::import('application.vendors.*');
     require_once 'Tp/UploadFile.class.php';
     $upload = new UploadFile();
     // 设置上传文件大小
     $maxSize = isset($params['maxSize']) ? $params['maxSize'] : $conf['upload_max_size'];
     $upload->maxSize = $maxSize * 1024;
     // 设置上传文件类型
     $upload->allowExts = isset($params['allowExts']) ? explode(',', $params['allowExts']) : explode(',', $conf['upload_allow_ext']);
     // 设置附件上传目录
     $upload->savePath = self::_saveRule($params);
     // 设置需要生成缩略图,仅对图像文件有效
     $upload->thumb = isset($params['thumb']) ? $params['thumb'] : $conf['thumb'];
     // 设置需要生成缩略图的文件后缀
     $upload->thumbPrefix = 'thumb_';
     // 生产2张缩略图
     // 设置缩略图最大宽度
     $upload->thumbMaxWidth = $params['thumbSize'][0];
     // 设置缩略图最大高度
     $upload->thumbMaxHeight = $params['thumbSize'][1];
     // 设置上传文件规则
     $upload->saveRule = uniqid;
     // 删除原图
     $upload->thumbRemoveOrigin = false;
     if (!$upload->upload()) {
         return $upload->getErrorMsg();
     } else {
         $fileinfo = $upload->getUploadFileInfo();
         require_once 'Tp/Image.class.php';
         Image::water($fileget['pathname'], './' . $conf['upload_water_file'], null, $conf['upload_water_trans']);
         foreach ($fileinfo as $key => $row) {
             if (true == $upload->thumb) {
                 $fileinfo[$key]['thumb'] = $upload->thumbPrefix . $fileinfo[$key]['savename'];
             }
             $fileinfo[$key]['pathname'] = $upload->savePath . $fileinfo[$key]['savename'];
             $fileinfo[$key]['paththumbname'] = $upload->savePath . $upload->thumbPrefix . $fileinfo[$key]['savename'];
             if ($conf['upload_water_status'] == 'open') {
                 Image::water($fileinfo[$key]['pathname'], './' . $conf['upload_water_file'], null, $conf['upload_water_trans']);
             }
         }
         return $fileinfo;
     }
 }
开发者ID:tecshuttle,项目名称:51qsk,代码行数:52,代码来源:XUpload.php

示例11: _upload

 protected function _upload()
 {
     import("@.ORG.UploadFile");
     $upload = new UploadFile();
     //设置上传文件大小
     $upload->maxSize = 3292200;
     //设置上传文件类型
     $upload->allowExts = explode(',', 'jpg,gif,png,jpeg');
     //设置附件上传目录
     $upload->savePath = 'Tpl/default/Public/Uploads/';
     //设置需要生成缩略图,仅对图像文件有效
     $upload->thumb = true;
     // 设置引用图片类库包路径
     $upload->imageClassPath = '@.ORG.Image';
     //设置需要生成缩略图的文件后缀
     $upload->thumbPrefix = 'm_,s_';
     //生产2张缩略图
     //设置缩略图最大宽度
     $upload->thumbMaxWidth = '400,100';
     //设置缩略图最大高度
     $upload->thumbMaxHeight = '400,100';
     //设置上传文件规则
     $upload->saveRule = uniqid;
     //删除原图
     $upload->thumbRemoveOrigin = true;
     if (!$upload->upload()) {
         //捕获上传异常
         $this->error($upload->getErrorMsg());
     } else {
         //取得成功上传的文件信息
         $uploadList = $upload->getUploadFileInfo();
         import("@.ORG.Image");
         //给m_缩略图添加水印, Image::water('原文件名','水印图片地址')
         Image::water($uploadList[0]['savepath'] . 'm_' . $uploadList[0]['savename'], '../Public/Images/logo2.png');
         $_POST['image'] = $uploadList[0]['savename'];
     }
     if ($list !== false) {
         //$this->success('上传图片成功!');
         return $uploadList;
     } else {
         return false;
         //$this->error('上传图片失败!');
     }
 }
开发者ID:baowzh,项目名称:adminrightlist,代码行数:44,代码来源:goodsAction.class.php

示例12: upload

 function upload()
 {
     import("ORG.Net.UploadFile");
     $upload = new UploadFile();
     //检查客户端上传文件参数设置
     if (isset($_POST['_uploadFileSize']) && is_numeric($_POST['_uploadFileSize'])) {
         //设置上传文件大小
         $upload->maxSize = $_POST['_uploadFileSize'];
     } else {
         $upload->maxSize = C('FILE_UPLOAD_MAXSIZE');
     }
     /*if (! empty ( $_POST ['_uploadFileType'] )) {
     		//设置上传文件类型
     		$upload->allowExts = explode ( ',', strtolower ( $_POST ['_uploadFileType'] ) );
     		} else {
     		$upload->allowExts = explode ( ',', C ( 'FILE_UPLOAD_ALLOWEXTS' ) );
     		}*/
     $upload->allowExts = explode(',', C('FILE_UPLOAD_ALLOWEXTS'));
     if (!empty($_POST['_uploadSavePath'])) {
         //设置附件上传目录
         $upload->savePath = $_POST['_uploadSavePath'];
     } else {
         $upload->savePath = "./Public/Uploads/" . MODULE_NAME . "/";
     }
     //是否自动命名
     if (GetSettValue('uploadsaveRule') == 1) {
         if (isset($_POST['_uploadSaveRule'])) {
             //设置附件命名规则
             $upload->saveRule = $_POST['_uploadSaveRule'];
         } else {
             $upload->saveRule = 'uniqid';
         }
     }
     if (MODULE_NAME == 'Products') {
         //创建目录
         $upload->savePath = $upload->savePath . toDate(time(), 'Ymd') . "/";
         if (!file_exists("{$upload->savePath}")) {
             mk_dir($upload->savePath);
         }
         //设置需要生成缩略图,仅对图像文件有效
         $upload->thumb = true;
         //设置需要生成缩略图的文件后缀
         //$upload->thumbSuffix = "_thumb";
         //设置缩略图最大宽度
         $upload->thumbMaxWidth = GetSettValue('ImgThumbW');
         //设置缩略图最大高度
         $upload->thumbMaxHeight = GetSettValue('ImgThumbH');
     }
     $upload->uploadReplace = true;
     if (!$upload->upload()) {
         $error = $upload->getErrorMsg();
         $this->ajaxReturn('', $error, 0);
     } else {
         $uploadSuccess = true;
         $uploadList = $upload->getUploadFileInfo();
         //是否打上水印
         $imgwater = GetSettValue('ImgWater');
         $ImageWaterAlpha = GetSettValue('ImageWaterAlpha');
         if (empty($ImageWaterAlpha)) {
             $ImageWaterAlpha = 80;
         }
         import("ORG.Util.Image");
         foreach ($uploadList as $key => $file) {
             $savename['savename'] = $upload->savePath . $file['savename'];
             if ($imgwater == 1) {
                 if (GetSettValue('is_only_proimg_water') == 1 && MODULE_NAME == 'Products') {
                     Image::water($savename['savename'], GetSettValue('ImgWaterPath'), GetSettValue('ImgWaterPos'), '', $ImageWaterAlpha);
                 } elseif (GetSettValue('is_only_proimg_water') == 0) {
                     Image::water($savename['savename'], GetSettValue('ImgWaterPath'), GetSettValue('ImgWaterPos'), '', $ImageWaterAlpha);
                 }
             }
             $savename['name'] = $file['name'];
         }
         $this->ajaxReturn($savename, '上传成功!', 1);
     }
 }
开发者ID:dalinhuang,项目名称:concourse,代码行数:76,代码来源:AdminCommAction.class.php

示例13: save

 /**
 * 保存图片
 * @param array $key $_FILES 中的键名 为空则保存 $_FILES 中的所有图片
 * @param string $dir 保存的目录 为空则保存到临时目录
 * @param bool $is_thumb 是否缩略图片
 * @param array $whs 缩略图大小信息 为空则取后台设置,并返回 大图键名big 小图键名small
 	可生成多个缩略图
 		数组 参数1 为宽度,
 			 参数2为高度,
 			 参数3为处理方式:0(缩放,默认),1(剪裁),
 			 参数4为是否水印 默认为 0(不生成水印)
 	array(
 			'thumb1'=>array(300,300,0,0),
 			'thumb2'=>array(100,100,0,0),
 			...
 		),
 * @param bool $is_delete_origin 是否删除原图(当有缩略图时,此设置才生效)
 * @param bool $is_water 是否水印
 * @return array
 	如果只有一个图片,则返回
 		array(
 			'name'=>图片名称,
 			'url'=>原图web路径,
 			'path'=>原图物理路径,
 			有略图时
 			'thumb'=>array(
 				'thumb1'=>array('url'=>web路径,'path'=>物理路径),
 				'thumb2'=>array('url'=>web路径,'path'=>物理路径),
 				...
 			)
 		)
 		如果有多个图片,则返回(key 为 $_FILES 中的键名)
 		array(
 			'key'=>array(
 				'name'=>图片名称,
 				'url'=>原图web路径,
 				'path'=>原图物理路径,
 				有略图时
 				'thumb'=>array(
 					'thumb1'=>array('url'=>web路径,'path'=>物理路径),
 					'thumb2'=>array('url'=>web路径,'path'=>物理路径),
 					...
 				)
 			)
 			....
 		)
 */
 public function save($key = '', $dir = 'temp', $is_thumb = false, $whs = array(), $is_delete_origin = false, $is_water = false)
 {
     global $_FANWE;
     include_once fimport('class/image');
     $image = new Image();
     if (intval($_FANWE['setting']['max_upload']) > 0) {
         $image->max_size = intval($_FANWE['setting']['max_upload']);
     }
     $list = array();
     if (empty($key)) {
         foreach ($_FILES as $fkey => $file) {
             $list[$fkey] = false;
             $image->init($file, $dir);
             if ($image->save()) {
                 $list[$fkey] = array();
                 $list[$fkey]['url'] = $image->file['target'];
                 $list[$fkey]['path'] = $image->file['local_target'];
                 $list[$fkey]['name'] = $image->file['prefix'];
             }
         }
     } else {
         $list[$key] = false;
         $image->init($_FILES[$key], $dir);
         if ($image->save()) {
             $list[$key] = array();
             $list[$key]['url'] = $image->file['target'];
             $list[$key]['path'] = $image->file['local_target'];
             $list[$key]['name'] = $image->file['prefix'];
         }
     }
     $water_image = FANWE_ROOT . $_FANWE['setting']['water_image'];
     $water_mark = intval($_FANWE['setting']['water_mark']);
     $alpha = intval($_FANWE['setting']['water_alpha']);
     $place = intval($_FANWE['setting']['water_position']);
     if ($is_thumb) {
         if (empty($whs)) {
             $big_width = intval($_FANWE['setting']['big_width']);
             $big_height = intval($_FANWE['setting']['big_height']);
             $small_width = intval($_FANWE['setting']['small_width']);
             $small_height = intval($_FANWE['setting']['small_height']);
             $thumb_type = intval($_FANWE['setting']['auto_gen_image']);
             $whs = array('big' => array($big_width, $big_height, $thumb_type, $water_mark), 'small' => array($small_width, $small_height, 1, 0));
         }
     }
     foreach ($list as $lkey => $item) {
         if ($is_thumb) {
             foreach ($whs as $tkey => $wh) {
                 $list[$lkey]['thumb'][$tkey]['url'] = false;
                 $list[$lkey]['thumb'][$tkey]['path'] = false;
                 if ($wh[0] > 0 || $wh[1] > 0) {
                     $thumb_bln = false;
                     $thumb_type = isset($wh[2]) ? intval($wh[2]) : 0;
                     if ($thumb = $image->thumb($item['path'], $wh[0], $wh[1], $thumb_type)) {
//.........这里部分代码省略.........
开发者ID:dalinhuang,项目名称:concourse,代码行数:101,代码来源:image.service.php

示例14: upload

 /**
  * 图片上传处理
  * @param 
  * @return 
  */
 public function upload()
 {
     import('ORG.Net.UploadFile');
     $config = array('autoSub' => true, 'subType' => 'date', 'dateFormat' => 'Ymd', 'savePath' => './uploads/');
     $upload = new UploadFile($config);
     if ($upload->upload()) {
         $info = $upload->getUploadFileInfo();
         //引入自己写的Imaage类
         import('Class.Image', APP_PATH);
         //实例化水印(water)方法
         Image::water('./uploads/' . $info[0]['savename']);
         echo json_encode(array('url' => $info[0]['savename'], 'title' => htmlspecialchars($_POST['pictitle'], ENT_QUOTES), 'original' => $info[0]['name'], 'state' => 'SUCCESS'));
     } else {
         echo json_encode(array('state' => $upload->getErrorMsg()));
     }
     /**
      * 向浏览器返回数据json数据
      * {
      *   'url'      :'a.jpg',   //保存后的文件路径
      *   'title'    :'hello',   //文件描述,对图片来说在前端会添加到title属性上
      *   'original' :'b.jpg',   //原始文件名
      *   'state'    :'SUCCESS'  //上传状态,成功时返回SUCCESS,其他任何值将原样返回至图片上传框中
      * }
      */
 }
开发者ID:badguy2015,项目名称:asugar,代码行数:30,代码来源:BlogAction.class.php

示例15: Upload

 case 'uploadimage':
     /* 上传涂鸦 */
 /* 上传涂鸦 */
 case 'uploadscrawl':
     /* 上传视频 */
 /* 上传视频 */
 case 'uploadvideo':
     /* 上传文件 */
 /* 上传文件 */
 case 'uploadfile':
     $upload = new Upload($CONFIG['imagePathFormat']);
     if ($info = $upload->upload()) {
         //加水印
         if ($_GET['water'] == 1) {
             $image = new Image();
             $image->water($info[0]['path']);
         }
         $info = $info[0];
         $result = json_encode(array("state" => "SUCCESS", "url" => $info['url'], "title" => $info['filename'], "original" => $info['name'], "type" => $info['ext'], "size" => $info['size']));
     } else {
         $result = json_encode(array('state' => $upload->error));
     }
     break;
     /* 列出图片 */
 /* 列出图片 */
 case 'listimage':
     $result = (include "action_list.php");
     break;
     /* 列出文件 */
 /* 列出文件 */
 case 'listfile':
开发者ID:www2511550,项目名称:ECSHOP,代码行数:31,代码来源:ueditor_upload.php


注:本文中的Image::water方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。