当前位置 : 主页 > 网络编程 > JavaScript >

vue-wangEditor

来源:互联网 收集:自由互联 发布时间:2021-06-28
wangEditor.vue edit.vue {{form.content}} *.php(thinkphp) # wangEditor 图片上传 public function upload() { $path = 'Uploads/images/wangEditor/'; $upload = new \Think\Upload();// 实例化上传类 $upload-maxSize = 5 * 1024 * 1024;// 设置
wangEditor.vue
 


edit.vue
 
*.php(thinkphp)
# wangEditor 图片上传
    public function upload()
    {
        $path = 'Uploads/images/wangEditor/';
        $upload = new \Think\Upload();// 实例化上传类
        $upload->maxSize = 5 * 1024 * 1024;// 设置附件上传大小
        $upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
        $upload->rootPath = './' . $path; // 设置附件上传根目录
        @mkdir($upload->rootPath, 0755, true);
        $data = array();
        foreach ($_FILES as $k => $v){
            $info = $upload->uploadOne($v);
            if ($info){
                $url = $path . $info['savepath'] . $info['savename'];
                $url = $_REQUEST['domain'] ? getDomain() . $url : $url;
                $data[] = $url;
            }
        }
        if ($data){
            echo json_encode(array('errno'=>0,'data'=>$data));
        }else{
            echo json_encode(array('errno'=>1));
        }
    }





    # 根域名
function getDomain()
{
    $sys_protocal = isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://';
    return $sys_protocal . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '') . '/';
}
网友评论