thinkphp5给文本编辑器ueditor图片上传的路径增加网址

thinkphp5给文本编辑器ueditor图片上传的路径增加网址

找到上传图片类

在这里插入图片描述
在thinkphpwu\public\static\hadmin\lib\ueditor\1.4.3\php中Uploader.class.php 类
查找getFileInfo方法

    /**
     * 获取当前上传成功文件的各项信息
     * @return array
     */
    public function getFileInfo()
    {
    
    
        return array(
            "state" => $this->stateInfo,
            "url" => $this->fullName,
            "title" => $this->fileName,
            "original" => $this->oriName,
            "type" => $this->fileType,
            "size" => $this->fileSize
        );
    }

修改控制器定义域名

在这里插入图片描述
在这里插入图片描述

define('DOMAIN','http://app.thinkphpwu.com');

修改getFileInfo 方法

加入

“url” => DOMAIN.$this->fullName,

    /**
     * 获取当前上传成功文件的各项信息
     * @return array
     */
    public function getFileInfo()
    {
    
    
        return array(
            "state" => $this->stateInfo,
            "url" => DOMAIN.$this->fullName,
            "title" => $this->fileName,
            "original" => $this->oriName,
            "type" => $this->fileType,
            "size" => $this->fileSize
        );
    }

验证

在这里插入图片描述

<p>
    <img src="http://app.thinkphpwu.com/ueditor/php/upload/image/20210109/1610186390184928.png" title="1610186390184928.png" alt="company_notice.png"/>
</p>

猜你喜欢

转载自blog.csdn.net/guo_qiangqiang/article/details/112396856