function layuiUpload($path = '') {
$upload = new \Think\Upload();
$upload->maxSize = 2097152;
$upload->exts = ['jpg', 'jpeg', 'png', 'gif', 'doc', 'docx', 'xls', 'xlsx'];
$savePath = $path ? './upload/' . $path . '/' : './upload/';
$upload->rootPath = $savePath;
$upload->autoSub = false;
$res = $upload->upload();
if (\stristr($res['file']['type'], 'image')) { // 如果上传的是图片进行压缩
$image = new \Think\Image();
$image->open($savePath . $res['file']['savename']);
$image->thumb(800, 800)->save($savePath . $res['file']['savename']);
}
$this->ajaxReturn([
'code' => 0,
'msg' => '',
'data' => [
'fullSrc' => 'http://' . \currentDomain() . \str_replace('./', '/', $savePath) . $res['file']['savename'],
'src' => \str_replace('./', '/', $savePath) . $res['file']['savename'],
'fileName' => $res['file']['savename'],
],
]);
}