layui layedit
作者:互联网
<textarea
id="edit"
name="article_content"
style="display: none;"
>{$row[article_content]}</textarea>
layui.use(['layedit'], function () {
var 'form', 'jquery', 'laydate', 'upload',layedit = layui.layedit
layedit.set({
uploadImage: {
url: '__CONTROLLER__/upload2?path=article' //接口url
}
})
layedit.build('edit')
})
function upload2($path=''){
$upload=new \Think\Upload(); //实例化上传类
$upload->maxSize=99999999; //设置附件上传大小
$upload->exts=['jpg','jpeg','png','gif']; // 设置附件上传类型
$savePath=$path?'./upload/'.$path.'/':'./upload/';
$upload->rootPath=$savePath; // 设置附件上传目录
$upload->autoSub=false;
// 上传文件
$info=$upload->upload();
$this->ajaxReturn([
'code'=>0,
'msg'=>'',
'data'=>[
'src'=>'https://'.$_SERVER['HTTP_HOST'].\str_replace('./','/',$savePath).$info[file][savename],
],
]);
}
标签:layui,upload,savePath,path,上传,layedit 来源: https://www.cnblogs.com/sunr/p/16672047.html