<?php
if (!defined('IN_59MIAO'))
{
	exit('Access Defined');
}
class UploadAction extends Action{	
	public function __construct(){
		parent::__construct();				
	}
	/*
	 * 
	 *$thumbnail = new ImageResize();
	  $thumbnail->resizeimage(源图片完整路径, 缩略图宽度, 缩略图高度, 是否剪裁（0或者1）, 新图片完整路径);
	 */
	public function index(){		
		$width=$_POST['width'];
		$height=$_POST['height'];
		if($_POST['cut']=='true'){
			$cut=0;  //不剪切
		}
		else{
			$cut=1;
		}
		if (isset($_POST['send'])) {	
			$_fileupload = new FileUpload('pic',MAX_FILE_SIZE);
			$sourcepath = $_fileupload->getSourcePath();
			$minpath=$_fileupload->getMinPath();			
			$_img = new ImageResize();
			$_img->resizeimage($sourcepath, $width, $height, $cut, $minpath);
			Tool::alertOpenerClose('图片上传成功！',$sourcepath,$minpath);	 //原图片名称和新图片名称
		} 
	}
	public function upfile(){
		$width=isset($_GET['width'])?$_GET['width']:'';
		$height=isset($_GET['height'])?$_GET['height']:'';
		$cut=isset($_GET['cut'])?$_GET['cut']:'';
		$this->_tpl->assign('width',$width);
		$this->_tpl->assign('height',$height);
		$this->_tpl->assign('cut',$cut);
		$this->_tpl->display(SMARTY_ADMIN.'public/upload.tpl');		
	}
		
}
?>