文件上传
获取上传文件
获取上传文件数据
/**
* 默认方法
*
* @cp_api post, /hello, hello
* @cp_request f:file|上传文件|1
* @throws
*/
function index()
{
$Uploader = new Uploader();
$uploaderData = $this->input('f')->uploader($Uploader);
$this->json(1, $uploaderData);
}
f:file
生成文件上传表单
限制文件大小
$Uploader = new Uploader();
$Uploader->setAllowSize(20000);
限制文件后缀
$Uploader = new Uploader();
$Uploader->setAllowExtension('jpg|gif');
使用图片过滤器
$Uploader = new Uploader();
$Filter = new Image();
$Uploader->addFilter($Filter);
限制图片最小高宽 200x200
$Filter->setWidthHeight(200, 200);
实现
Cross\Lib\Upload\IFilter
接口扩展支持更多过滤器