public function uploadLicense()
{
$file = 'file';
$savename = $this->hcode.'_license';
$path = 'uploads/index/unit_info/license';
parent::uploadImg($file, $savename, $path);
}
// 设置大小2m
protected function uploadImg($file, $savename, $path , $size, $ext)
{
$file = $this->request->file($file);
$path = ROOT_PATH . 'public' . DS . $path;
$size = $size * 1024;
$info = $file->validate(['size' => $size, 'ext'=> $ext])->move($path, $savename, true);
if ($info) {
$savename = str_replace('\\', "/", $info->getSaveName());
$this->result($savename, 200, '上传成功');
} else {
$this->result('', 500, $file->getError());
}
}