<?php

/**
 *--------------------------------------
 * 上传文件
 *--------------------------------------
 * @project		: uwa
 * @author		: cblee
 * @created		: 2012-11-12
 * @copyright	: (c)2012 AsThis
 *--------------------------------------
 */

class UploadCtrlr extends MemberCtrlr
{
	/* 上传文件 */
	public function upload_file()
	{
		if(!I('upload', 60))
		{
			return;
		}

		/* file field name */
		$field = 'upload';
		/* 文件类型, 如image, file, all */
		$typeSet = in_array(ARequest::get('type_set'), array('image', 'file', 'all')) ? ARequest::get('type_set') : 'image';
		/* 是否缩略图 */
		$thumb = ('yes' == ARequest::get('thumb')) ? true : false;
		/* 是否水印 */
		$watermark = ('yes' == ARequest::get('watermark')) ? true : false;
		/* 返回类型 normal, editor */
		$returnType = in_array(ARequest::get('return_type'), array('editor', 'normal')) ? ARequest::get('return_type') :'normal';
		/* 上传类型, 如archive, flink, ad */
		$uploadType = AFilter::is_word(ARequest::get('upload_type')) ? ARequest::get('upload_type') : 'archive';
		/* 编辑器函数编号 */
		$fn = intval(ARequest::get('CKEditorFuncNum'));

		/* 上传文件 */
		$result = M('Upload')->upload_file($field, $typeSet, $thumb, $watermark, $returnType, $uploadType, $fn);
		if(!empty($result['error']))
		{
			exit($result['error']);
		}
		exit($result['data']);

		I('upload');
	}

}


?>