ThinkPHP5整合LayUI编辑器图片上传

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

一、创建上传方法

public function uploadimg()
    {
        $image = $_FILES['file'];
        $filebase = file_get_contents($image['tmp_name']);
        $upimg = $this->uploadImage($filebase);
        $upfile['code'] = '0';
        $upfile['msg'] = '上传成功';
        $upfile['data']['src'] = $upimg;
        $upfile['data']['title'] = $image['name'];
        echo  json_encode($upfile);
    }

二、配置LayUI编辑器图片上传参数

layedit.set({
            uploadImage: {
                url: '{:url('pubblico/uploadimg')}' //接口url
            ,type: '' //默认post
            }
        });

========================================================================

LayUI文件上传

//单个上传
        layui.upload({
            url: '{:url('pubblico/uploadimg')}' //上传接口
            ,success: function(res){ //上传成功后的回调
               alert(res.data.src);
            }
        });



转载于:https://my.oschina.net/zhliang/blog/887457

你可能感兴趣的:(javascript,php,python)