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],
		],
	]);
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章