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


PHP image::thumb方法代码示例

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


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

示例1: _index

 public function _index($album, $sub_tool = FALSE)
 {
     # this is a hack for allowed sub_tools only.
     if (!is_object($album)) {
         $album = ORM::factory('album')->where('fk_site', $this->site_id)->find($album);
         if (!$album->loaded) {
             return $this->wrap_tool('album error, please contact support', 'album', $album);
         }
     }
     # set the thumbnail size USES TOGGLE:
     $thumb_size = (isset($album->toggle) and is_numeric($album->toggle)) ? $album->toggle : 75;
     # images
     $images = json_decode($album->images);
     if (NULL === $images or !is_array($images)) {
         return $this->wrap_tool('no images.', 'album', $album);
     }
     foreach ($images as $image) {
         $image->thumb = image::thumb($image->path, $thumb_size);
     }
     $display_view = empty($album->view) ? 'lightbox' : $album->view;
     $primary = $this->{$display_view}($album, $images);
     # add custom javascript;
     $primary->global_readyJS(self::javascripts($album));
     return $this->wrap_tool($primary, 'album', $album, $sub_tool);
 }
开发者ID:plusjade,项目名称:plusjade,代码行数:25,代码来源:album.php

示例2: manage

 public function manage()
 {
     $album = $this->get_parent('album');
     if ($_POST) {
         if (NULL === json_decode($_POST['images'])) {
             die('data is not properly formed JSON');
         }
         $album->images = $_POST['images'];
         $album->save();
         die('Album saved');
     }
     # images
     $images = json_decode($album->images);
     if (NULL === $images) {
         $images = array();
     }
     foreach ($images as $image) {
         $image->thumb = image::thumb($image->path);
     }
     $primary = new View('edit_album/manage');
     $primary->album = $album;
     $primary->images = $images;
     $primary->img_path = $this->assets->assets_url();
     die($primary);
 }
开发者ID:plusjade,项目名称:plusjade,代码行数:25,代码来源:edit_album.php

示例3: save

 /**
  * 储存文件
  * @param string $file 储存的文件
  * @return boolean
  */
 private function save($file)
 {
     $is_img = 0;
     $uploadFileName = mt_rand(1, 9999) . time() . "." . $file['ext'];
     $filePath = $this->path . $uploadFileName;
     if (in_array(strtolower($file['ext']), array("jpeg", "jpg", "bmp", "gif", "png")) && getimagesize($file['tmp_name'])) {
         $imgDir = C("UPLOAD_IMG_DIR") ? C("UPLOAD_IMG_DIR") . "/" : "";
         $filePath = $this->path . $imgDir . $uploadFileName;
         if (!$this->checkDir($this->path . $imgDir)) {
             $this->error = '图片上传目录创建失败或不可写';
             return false;
         }
         $is_img = 1;
     }
     if (!move_uploaded_file($file['tmp_name'], $filePath)) {
         $this->error('移动临时文件失败');
         return false;
     }
     if (!$is_img) {
         $filePath = ltrim(str_replace(ROOT_PATH, '', $filePath), '/');
         $arr = array("path" => $filePath, 'fieldname' => $file['fieldname'], 'image' => 0);
     } else {
         //处理图像类型文件
         $img = new image();
         $imgInfo = getimagesize($filePath);
         //对原图进行缩放
         if (C("UPLOAD_IMG_RESIZE_ON") && ($imgInfo[0] > C("UPLOAD_IMG_MAX_WIDTH") || $imgInfo[1] > C("UPLOAD_IMG_MAX_HEIGHT"))) {
             $img->thumb($filePath, $uploadFileName, C("UPLOAD_IMG_MAX_WIDTH"), C("UPLOAD_IMG_MAX_HEIGHT"), 5, $this->path);
         }
         //生成缩略图
         if ($this->thumbOn) {
             $args = array();
             if (empty($this->thumb)) {
                 array_unshift($args, $filePath);
             } else {
                 array_unshift($args, $filePath, "", "");
                 $args = array_merge($args, $this->thumb);
             }
             $thumbFile = call_user_func_array(array($img, "thumb"), $args);
         }
         //加水印
         if ($this->waterMarkOn) {
             $img->water($filePath);
         }
         $filePath = trim(str_replace(ROOT_PATH, '', $filePath), '/');
         if ($this->thumbOn) {
             $thumbFile = trim(str_replace(ROOT_PATH, '', $thumbFile), '/');
             $arr = array("path" => $filePath, "thumb" => $thumbFile, 'fieldname' => $file['fieldname'], 'image' => 1);
         } else {
             $arr = array("path" => $filePath, 'fieldname' => $file['fieldname'], 'image' => 1);
         }
     }
     $arr['path'] = preg_replace('@\\./@', '', $arr['path']);
     //上传时间
     $arr['uptime'] = time();
     $info = pathinfo($filePath);
     $arr['fieldname'] = $file['fieldname'];
     $arr['basename'] = $info['basename'];
     $arr['filename'] = $info['filename'];
     $arr['size'] = $file['size'];
     $arr['ext'] = $file['ext'];
     $dir = str_ireplace("\\", "/", dirname($arr['path']));
     $arr['dir'] = substr($dir, "-1") == "/" ? $dir : $dir . "/";
     return $arr;
 }
开发者ID:jyht,项目名称:v5,代码行数:70,代码来源:Upload.class.php

示例4: clip_thumb

 public static function clip_thumb($sourcefile, $destfile, $forcedwidth = 80, $forcedheight = 80)
 {
     // 获取原图片宽高
     $getimgsize = getimagesize($sourcefile);
     if (empty($getimgsize)) {
         return 0;
     } else {
         $src_width = $getimgsize[0];
         $src_height = $getimgsize[1];
         if ($src_width == 0 || $src_height == 0) {
             return 0;
         }
     }
     $src_scale = $src_width / $src_height;
     $des_scale = $forcedwidth / $forcedheight;
     if ($src_width <= $forcedwidth && $src_height <= $forcedheight) {
         $des_width = $src_width;
         $des_height = $src_height;
         $n = image::clip($sourcefile, $destfile, 0, 0, $des_width, $des_height);
         return filesize($destfile);
         // 原图为横着的矩形
     } elseif ($src_scale >= $des_scale) {
         // 以原图的高度作为标准,进行缩略
         $des_height = $src_height;
         $des_width = $src_height / $des_scale;
         $n = image::clip($sourcefile, $destfile, 0, 0, $des_width, $des_height);
         if ($n <= 0) {
             return 0;
         }
         $r = image::thumb($destfile, $destfile, $forcedwidth, $forcedheight);
         return $r['filesize'];
         // 原图为竖着的矩形
     } else {
         // 以原图的宽度作为标准,进行缩略
         $des_width = $src_width;
         $des_height = $src_width / $des_scale;
         /* echo "src_scale: $src_scale, src_width: $src_width, src_height: $src_height \n";
            echo "des_scale: $des_scale, forcedwidth: $forcedwidth, forcedheight: $forcedheight \n";
            echo "des_width: $des_width, des_height: $des_height \n";
            exit; */
         $n = image::clip($sourcefile, $destfile, 0, 0, $des_width, $des_height);
         if ($n <= 0) {
             return 0;
         }
         $r = image::thumb($destfile, $destfile, $forcedwidth, $forcedheight);
         return $r['filesize'];
     }
 }
开发者ID:hexcode007,项目名称:yfcms,代码行数:48,代码来源:Image.class.php

示例5: json_encode

//上传成功文件物理路径
$info = pathinfo($field);
$fileData = array();
$fileData[0]['path'] = $field;
//上传后的大图
$fileData[0]['url'] = __ROOT__ . '/' . $field;
//上传后的大图URL
$json = array();
$json['state'] = $state;
$json['fid'] = md5($field);
if (getimagesize($field)) {
    //图片裁切处理
    $img = new image();
    $img->water($field);
    $json['thumb']['file'] = __ROOT__ . '/' . $field;
    $json['thumb']['w'] = $display_width;
    $json['thumb']['h'] = $display_height;
}
if ($imagesize && getimagesize($field)) {
    //图片裁切处理
    $n = 1;
    for ($i = 0; $i < count($size); $i += 2) {
        $toFile = $info['filename'] . $n . '.' . $info['extension'];
        $img->thumb($field, $toFile, '', $size[$i], $size[$i + 1], $thumb_type);
        $fileData[$n]['path'] = $info['dirname'] . '/' . $toFile;
        $n++;
    }
}
$json['file'] = $fileData;
echo json_encode($json);
exit;
开发者ID:com-itzcy,项目名称:hdjob,代码行数:31,代码来源:hd_upload.php

示例6: save

    /**
     * 储存文件
     * @param string $file 储存的文件
     * @return boolean
     */
    private function save($file)
    {
        $is_img = 0;
        $uploadFileName = mt_rand(1, 9999) . time() . "." . $file['ext'];
        $filePath = $this->path . $uploadFileName;
        if (in_array(strtolower($file ['ext']), array("jpeg", "jpg", "bmp", "gif", "png")) && getimagesize($file ['tmp_name'])) {
            $imgDir = C("UPLOAD_IMG_DIR") ? C("UPLOAD_IMG_DIR") . "/" : "";
            $filePath = $this->path . $imgDir . $uploadFileName;
            if (!$this->checkDir($this->path . $imgDir)) {
                $this->error = L("upload_save_error1");
                return false;
            }
            $is_img = 1;
        }
        if (!move_uploaded_file($file ['tmp_name'], $filePath)) {
            $this->error(L("upload_save_error2"));
            return false;
        }

        if (!$is_img) {
            $filePath = ltrim(str_replace(PATH_ROOT, '', $filePath), '/');
            return array("path" => $filePath, 'fieldname' => $file['fieldname']);
        }
        //处理图像类型文件
        $img = new image ();
        //对原图进行缩放
        if (C("UPLOAD_IMG_RESIZE_ON")) {
            $img->thumb($filePath, $uploadFileName, '', C("UPLOAD_IMG_MAX_WIDTH"), C("UPLOAD_IMG_MAX_HEIGHT"), 5);
        }
        //生成缩略图
        if ($this->thumbOn) {
            $args = array();
            if (empty($this->thumb)) {
                array_unshift($args, $filePath);
            } else {
                array_unshift($args, $filePath, "", "");
                $args = array_merge($args, $this->thumb);
            }
            $thumbFile = call_user_func_array(array($img, "thumb"), $args);
        }
        //加水印
        if ($this->waterMarkOn) {
            $img->water($filePath);
        }
        $filePath = ltrim(str_replace(ROOT_PATH, '', $filePath), '/');
        $arr = array();
        if ($this->thumbOn) {
            $thumbFile = ltrim(str_replace(PATH_ROOT, '', $thumbFile), '/');
            $arr = array("path" => $filePath, "thumb" => $thumbFile);
        } else {
            $arr = array("path" => $filePath);
        }
        return array_merge($arr, $file);
    }
开发者ID:happyun,项目名称:tuan,代码行数:59,代码来源:Upload.class.php

示例7: uploadavatar

	/**
	 *  上传头像处理
	 *  传入头像压缩包,解压到指定文件夹后删除非图片文件
	 */
	public function uploadavatar() {
		
		//根据用户id创建文件夹
		if(isset($this->data['uid']) && isset($this->data['avatardata'])) {
			$this->uid = intval($this->data['uid']);
			$this->avatardata = $this->data['avatardata'];
		} else {
			exit('0');
		}
		
		$dir1 = ceil($this->uid / 10000);
		$dir2 = ceil($this->uid % 10000 / 1000);
		
		//创建图片存储文件夹
		$avatarfile = pc_base::load_config('system', 'upload_path').'avatar/';
		$dir = $avatarfile.$dir1.'/'.$dir2.'/'.$this->uid.'/';
		if(!file_exists($dir)) {
			mkdir($dir, 0777, true);
		}
		//存储flashpost图片
		$filename = $dir.'180x180.jpg';

		$fp = fopen($filename, 'w');
		fwrite($fp, $this->avatardata);
		fclose($fp);

		$avatararr = array('180x180.jpg', '30x30.jpg', '45x45.jpg', '90x90.jpg');
		$files = glob($dir."*");
		foreach($files as $_files) {
			if(is_dir($_files)) dir_delete($_files);
			if(!in_array(basename($_files), $avatararr)) @unlink($_files);
		}
		if($handle = opendir($dir)) {
		    while(false !== ($file = readdir($handle))) {
				if($file !== '.' && $file !== '..') {
					if(!in_array($file, $avatararr)) {
						@unlink($dir.$file);
					} else {
						$info = @getimagesize($dir.$file);
						if(!$info || $info[2] !=2) {
							@unlink($dir.$file);
						}
					}
				}
		    }
		    closedir($handle);    
		}

		pc_base::load_sys_class('image','','0');
		$image = new image(1,0);
		$image->thumb($filename, $dir.'30x30.jpg', 30, 30);
		$image->thumb($filename, $dir.'45x45.jpg', 45, 45);
		$image->thumb($filename, $dir.'90x90.jpg', 90, 90);
		
		$this->db->update(array('avatar'=>1), array('uid'=>$this->uid));
		exit('1');
	}
开发者ID:heqishengcai,项目名称:phpcms,代码行数:61,代码来源:index.php

示例8: image

             $image->watertext();
         }
     }
     if ($DT['water_type'] && $DT['water_com'] && $_groupid > 5) {
         $image = new image(DT_ROOT . '/' . $saveto);
         $image->text = $_company;
         $image->pos = 5;
         $image->watertext();
     }
     if ($from == 'photo') {
         $DT['thumb_album'] = 0;
     }
     $image = new image(DT_ROOT . '/' . $do->saveto);
     $image->thumb($width, $height, $DT['thumb_album']);
     $image = new image(DT_ROOT . '/' . $middle);
     $image->thumb($DT['middle_w'], $DT['middle_h'], $DT['thumb_album']);
     if ($DT['water_middle'] && $DT['water_type']) {
         if ($DT['water_type'] == 2) {
             $image = new image(DT_ROOT . '/' . $middle);
             $image->waterimage();
         } else {
             if ($DT['water_type'] == 1) {
                 $image = new image(DT_ROOT . '/' . $middle);
                 $image->watertext();
             }
         }
     }
 } else {
     if ($from == 'editor') {
         if ($_groupid == 1 && !isset($watermark)) {
             $DT['water_type'] = 0;
开发者ID:hcd2008,项目名称:destoon,代码行数:31,代码来源:upload.php

示例9: message

         if (!$img_info || $img_info[0] < 128 || $img_info[1] < 128) {
             file_del($file);
         }
         $img_info or message($L['avatar_img_t']);
         $img_info[0] >= 128 or message($L['avatar_img_w']);
         $img_info[1] >= 128 or message($L['avatar_img_h']);
         $par = 'auth=' . encrypt($_userid . '|' . $_username, DT_KEY . 'AVATAR');
         require DT_ROOT . '/include/image.class.php';
         $image = new image($file);
         $image->thumb(128, 128);
         $par .= '&pic1=' . urlencode(base64_encode(file_get($file)));
         $image = new image($file);
         $image->thumb(48, 48);
         $par .= '&pic2=' . urlencode(base64_encode(file_get($file)));
         $image = new image($file);
         $image->thumb(20, 20);
         $par .= '&pic3=' . urlencode(base64_encode(file_get($file)));
         file_del($file);
         $arr = dcurl(DT_PATH . 'api/avatar/upload.php', $par);
         if (strpos($arr, ':1}') !== false) {
             dheader('?itemid=' . $DT_TIME);
         }
         dalert($L['avatar_img_e'] . $arr, '?itemid=' . $DT_TIME);
     } else {
         message($upload->errmsg);
     }
     break;
 case 'delete':
     if ($avatar) {
         $img = array();
         $img[1] = useravatar($_userid, 'large', 0, 2);
开发者ID:hiproz,项目名称:zhaotaoci.cc,代码行数:31,代码来源:avatar.inc.php

示例10: foreach

<?php 
$class = 'albums' == $mode ? 'to_album' : 'to_editor';
$tmb_size = 75;
foreach ($files as $path => $data) {
    $data = explode('|', $data);
    list($type, $name) = $data;
    # show files
    if ('file' == $type) {
        $css_id = str_replace('.', '_', $name);
        $path = str_replace(':', '/', $path);
        $url = $this->assets->assets_url() . '/' . $path;
        $url_thumb = image::thumb($url);
        $display_name = '10' < strlen($name) ? substr($name, 0, 10) . '...' : $name;
        $ext = strtolower(strrchr($name, "."));
        # if image show thumbnail
        $img = array_key_exists($ext, $image_types) ? "<img src='{$url_thumb}' class='{$class} image_file' rel='{$url}' title='{$name}' width='{$tmb_size}' height='{$tmb_size}' alt='{$path}'>" : "<img src='/_assets/images/admin/file.gif' title='{$name}' width='{$tmb_size}' height='{$tmb_size}' alt=''>";
        ?>
		<div id="<?php 
        echo $css_id;
        ?>
" class="file_asset asset" rel="<?php 
        echo $path;
        ?>
">
			<span class="icon info">&#160; &#160;</span>
			<?php 
        echo $img;
        ?>
			<span title="<?php 
        echo $name;
开发者ID:plusjade,项目名称:plusjade,代码行数:30,代码来源:folder.php

示例11: foreach

<?php 
if (!empty($sub_categories)) {
    echo "<div><b>Filter By Sub Category</b>{$sub_categories}</div>";
}
?>
<!-- end duplicated -->

<div class="list_showroom">
	<?php 
foreach ($items as $item) {
    # images
    $images = json_decode($item->images);
    if (!empty($images) and is_array($images)) {
        # show the thumb of the first image in the album.
        # echo kohana::debug($images);
        $small = image::thumb($images[0]->path, 0);
        $image = "<img src=\"{$img_path}/{$small}\" alt=\"{$images[0]->caption}\">";
    }
    ?>
		
		<div id="showroom_item_<?php 
    echo $item->id;
    ?>
" class="showroom_item" rel="<?php 
    echo $item->id;
    ?>
">
			<div class="item_name">
				<?php 
    echo $item->name;
    ?>
开发者ID:plusjade,项目名称:plusjade,代码行数:31,代码来源:list.php

示例12: foreach

	 <small>(<?php 
echo $items->count();
?>
 results)</small>
</div>

<div class="showroom_items_wrapper">
	<?php 
$counter = 0;
foreach ($items as $item) {
    # images
    $images = json_decode($item->images);
    if (!empty($images) and is_array($images)) {
        # show the thumb of the first image in the album.
        $full_path = $images[0]->path;
        $thumb = image::thumb($full_path, $thumb_size);
        $image = "<img src='{$img_path}/{$thumb}' width='{$thumb_size}' height='{$thumb_size}' alt='{$images[0]->caption}'>";
    }
    ?>
	
		<div id="showroom_item_<?php 
    echo $item->id;
    ?>
" class="showroom_item" rel="<?php 
    echo $item->id;
    ?>
">
			<?php 
    if (isset($image)) {
        ?>
				<div class="item_image"><a href="<?php 
开发者ID:plusjade,项目名称:plusjade,代码行数:31,代码来源:gallery.php

示例13: save_thumb

function save_thumb($content, $no, $width = 120, $height = 90)
{
    global $DT, $DT_TIME, $_userid;
    if (!$_userid || !$content) {
        return '';
    }
    $ext = 'jpg|jpeg|gif|png|bmp';
    if (!preg_match_all("/src=([\"|']?)([^ \"'>]+\\.({$ext}))\\1/i", $content, $matches)) {
        return '';
    }
    require_once DT_ROOT . '/include/image.class.php';
    $dftp = false;
    if ($DT['ftp_remote'] && $DT['remote_url']) {
        require_once DT_ROOT . '/include/ftp.class.php';
        $ftp = new dftp($DT['ftp_host'], $DT['ftp_user'], $DT['ftp_pass'], $DT['ftp_port'], $DT['ftp_path'], $DT['ftp_pasv'], $DT['ftp_ssl']);
        $dftp = $ftp->connected;
    }
    $urls = $oldpath = $newpath = array();
    $DT['uploaddir'] or $DT['uploaddir'] = 'Ym/d';
    foreach ($matches[2] as $k => $url) {
        if ($k == $no - 1) {
            $filedir = 'file/upload/' . timetodate($DT_TIME, $DT['uploaddir']) . '/';
            $filepath = DT_PATH . $filedir;
            $fileroot = DT_ROOT . '/' . $filedir;
            $file_ext = file_ext($url);
            $filename = timetodate($DT_TIME, 'H-i-s') . '-' . rand(10, 99) . '-' . $_userid . '.' . $file_ext;
            $newfile = $fileroot . $filename;
            if (file_copy($url, $newfile)) {
                if (is_image($newfile)) {
                    if (!@getimagesize($newfile)) {
                        file_del($newfile);
                        return '';
                    }
                    $image = new image($newfile);
                    $image->thumb($width, $height);
                }
                $newurl = linkurl($filepath . $filename);
                if ($dftp) {
                    $exp = explode("file/upload/", $newurl);
                    if ($ftp->dftp_put($filedir . $filename, $exp[1])) {
                        $newurl = $DT['remote_url'] . $exp[1];
                        file_del($newfile);
                    }
                }
                return $newurl;
            }
        }
    }
    unset($matches);
    return '';
}
开发者ID:hcd2008,项目名称:destoon,代码行数:51,代码来源:post.func.php

示例14: editAction

 public function editAction()
 {
     //判断是否添加
     if (trim($this->getRequest()->getPost('document_submit', 0))) {
         //获取数据
         $document_id = trim($this->getRequest()->getPost('document_id', 0));
         $pageId = $this->getRequest()->getPost('document_pageid', 0);
         $table_name = $this->getRequest()->getPost('table_name', 0);
         //**************依据模型处理与模型关联的数据表**********************
         $docData = $this->getRequest()->getPost();
         $document_catid = trim($this->getRequest()->getPost('document_catid', 0));
         if (!$document_catid) {
             echo '<script>alert("请选择正确的所属栏目!");window.history.go(-1);</script>';
             exit;
         }
         $document_detail = (array) $this->db_category->get_category_detail($document_catid);
         $modelid = $document_detail[0]['modelid'];
         $where = array("AND" => array("status" => 1, "modelid" => $modelid));
         //获取该模型的所有启用字段
         $fields = $this->db_modelFields->get_column_by_where("field", $where);
         //自动接收表单数据并过滤
         foreach ($docData as $key => $val) {
             if (in_array($key, $fields)) {
                 $data[$key] = trim($val);
             }
         }
         if (in_array('updatetime', $fields)) {
             $data['updatetime'] = $_SERVER['time'];
         }
         if (in_array('uid', $fields)) {
             $data['uid'] = $this->_user['uid'];
         }
         if (in_array('thumb', $fields)) {
             $fileInfo = $this->getRequest()->getFiles();
             //                var_dump($fileInfo);
             $filename = image::safe_name($fileInfo['thumb']['name'], '/uploadfile/image/');
             $data['thumb'] = image::thumb($fileInfo['thumb']['tmp_name'], '/uploadfile/image/' . $filename);
         }
         $data['catid'] = $document_catid;
         //            var_dump($data);die;
         //判断数据是否正常
         if (isset($data['title']) && empty($data['title'])) {
             echo '<script>alert("请填写标题!");window.history.go(-1);</script>';
             exit;
         }
         if (isset($data['content']) && empty($data['content'])) {
             echo '<script>alert("请填写内容!");window.history.go(-1);</script>';
             exit;
         }
         //将数据添加到表中
         if ($table_name == 'news') {
             $content = $data['content'];
             unset($data['content']);
             if ($this->db_document->document_update($document_id, $data, $table_name) && $this->db_document->document_update($document_id, array('content' => $content), 'news_data') || $this->db_document->document_update($document_id, $data, $table_name) || $this->db_document->document_update($document_id, array('content' => $content), 'news_data')) {
                 echo '<script>alert("操作成功");window.location.href="/admin/document/index?' . $pageId . '";</script>';
             } else {
                 echo '<script>alert("操作失败");window.history.go(-1);</script>';
             }
         } else {
             if ($id = $this->db_document->document_update($document_id, $data, $table_name)) {
                 echo '<script>alert("操作成功");window.location.href="/admin/document/index?' . $pageId . '";</script>';
             } else {
                 echo '<script>alert("操作失败");window.history.go(-1);</script>';
             }
         }
         exit;
     } else {
         Yaf_Controller_Abstract::redirect("/admin/document/index");
         exit;
     }
 }
开发者ID:290329416,项目名称:guahao,代码行数:71,代码来源:Document.php

示例15: upload

 /**
  * 附件上传方法
  * @param $field 上传字段
  * @param $alowexts 允许上传类型
  * @param $maxsize 最大上传大小
  * @param $overwrite 是否覆盖原有文件
  * @param $thumb_setting 缩略图设置
  * @param $watermark_enable  是否添加水印
  */
 function upload($field, $alowexts = '', $maxsize = 0, $overwrite = 0, $thumb_setting = array(), $watermark_enable = 1)
 {
     if (!isset($_FILES[$field])) {
         $this->error = UPLOAD_ERR_OK;
         return false;
     }
     if (empty($alowexts) || $alowexts == '') {
         $site_setting = $this->_get_site_setting($this->siteid);
         $alowexts = $site_setting['upload_allowext'];
     }
     $fn = $_GET['CKEditorFuncNum'] ? $_GET['CKEditorFuncNum'] : '1';
     $this->field = $field;
     $this->savepath = $this->upload_root . $this->upload_dir . date('Y/md/');
     $this->alowexts = $alowexts;
     $this->maxsize = $maxsize;
     $this->overwrite = $overwrite;
     $uploadfiles = array();
     $description = isset($GLOBALS[$field . '_description']) ? $GLOBALS[$field . '_description'] : array();
     if (is_array($_FILES[$field]['error'])) {
         $this->uploads = count($_FILES[$field]['error']);
         foreach ($_FILES[$field]['error'] as $key => $error) {
             if ($error === UPLOAD_ERR_NO_FILE) {
                 continue;
             }
             if ($error !== UPLOAD_ERR_OK) {
                 $this->error = $error;
                 return false;
             }
             $uploadfiles[$key] = array('tmp_name' => $_FILES[$field]['tmp_name'][$key], 'name' => $_FILES[$field]['name'][$key], 'type' => $_FILES[$field]['type'][$key], 'size' => $_FILES[$field]['size'][$key], 'error' => $_FILES[$field]['error'][$key], 'description' => $description[$key], 'fn' => $fn);
         }
     } else {
         $this->uploads = 1;
         if (!$description) {
             $description = '';
         }
         $uploadfiles[0] = array('tmp_name' => $_FILES[$field]['tmp_name'], 'name' => $_FILES[$field]['name'], 'type' => $_FILES[$field]['type'], 'size' => $_FILES[$field]['size'], 'error' => $_FILES[$field]['error'], 'description' => $description, 'fn' => $fn);
     }
     if (!dir_create($this->savepath)) {
         $this->error = '8';
         return false;
     }
     if (!is_dir($this->savepath)) {
         $this->error = '8';
         return false;
     }
     @chmod($this->savepath, 0777);
     if (!is_writeable($this->savepath)) {
         $this->error = '9';
         return false;
     }
     if (!$this->is_allow_upload()) {
         $this->error = '13';
         return false;
     }
     $aids = array();
     foreach ($uploadfiles as $k => $file) {
         $fileext = fileext($file['name']);
         if ($file['error'] != 0) {
             $this->error = $file['error'];
             return false;
         }
         if (!preg_match("/^(" . $this->alowexts . ")\$/", $fileext)) {
             $this->error = '10';
             return false;
         }
         if ($this->maxsize && $file['size'] > $this->maxsize) {
             $this->error = '11';
             return false;
         }
         if (!$this->isuploadedfile($file['tmp_name'])) {
             $this->error = '12';
             return false;
         }
         $temp_filename = $this->getname($fileext);
         $savefile = $this->savepath . $temp_filename;
         $savefile = preg_replace("/(php|phtml|php3|php4|jsp|exe|dll|asp|cer|asa|shtml|shtm|aspx|asax|cgi|fcgi|pl)(\\.|\$)/i", "_\\1\\2", $savefile);
         $filepath = preg_replace(new_addslashes("|^" . $this->upload_root . "|"), "", $savefile);
         if (!$this->overwrite && file_exists($savefile)) {
             continue;
         }
         $upload_func = $this->upload_func;
         if (@$upload_func($file['tmp_name'], $savefile)) {
             $this->uploadeds++;
             @chmod($savefile, 0644);
             @unlink($file['tmp_name']);
             $file['name'] = iconv("utf-8", CHARSET, $file['name']);
             $file['name'] = safe_replace($file['name']);
             $uploadedfile = array('filename' => $file['name'], 'filepath' => $filepath, 'filesize' => $file['size'], 'fileext' => $fileext, 'fn' => $file['fn']);
             $thumb_enable = is_array($thumb_setting) && ($thumb_setting[0] > 0 || $thumb_setting[1] > 0) ? 1 : 0;
             $image = new image($thumb_enable, $this->siteid);
             if ($thumb_enable) {
//.........这里部分代码省略.........
开发者ID:shenhua4286,项目名称:gxw,代码行数:101,代码来源:attachment.class.php


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