layui富文本上传图片

###前端代码
layedit.set({
uploadImage: {
url: ‘/Admin/Counsel/doUploadPic’
,type: ‘post’ //默认post
}
});
###后台
public function doUploadPic()//上传模块
{
$upload = new \Think\Upload();
$upload->maxSize = 3145728;
$upload->exts = array(‘jpg’, ‘gif’, ‘png’, ‘jpeg’);
$upload->rootPath = ‘./Uploads/’;
$upload->savePath = ‘/’;
$info = u p l o a d − > u p l o a d ( ) ; i f ( ! upload->upload(); if(! upload>upload();if(!info){
t h i s − > e r r o r ( this->error( this>error(upload->getError());
}else{
foreach($info as $file){
d a t a = ′ / U p l o a d s ′ . data = '/Uploads'. data=/Uploads.file[‘savepath’] . $file[‘savename’];
f i l e a = file_a= filea=data;
echo ‘{“code”:0,“msg”:“成功上传”,“data”:{“src”:"’.$file_a.’"}}’;
}
}
}

你可能感兴趣的:(layui)