PHP code example of guoguo882010 / ueditor-oss
1. Go to this page and download the library: Download guoguo882010/ueditor-oss library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
guoguo882010 / ueditor-oss example snippets
//阿里云 oss 配置
$ossConfig = [
'access_key_id' => 'key id',
'access_key_secret' => 'key secret',
// 桶名称
'bucket_name' => 'scb-sys',
// 阿里外网、内网url,自定义url
'endpoint' => 'http://oss-cn-chengdu.aliyuncs.com',
// 临时url超时时间,单位秒
'sign_timeout' => 3600,
];
//百度编辑器,后端图片处理
$baidu = new \RSHDSDK\UEditorOSS\UEditor($ossConfig);
//前台接收的百度编辑器 url 参数数组传给 action 方法,自动把图片上传到阿里 oss
$baidu->action($this->request->param());
//获取的数据,oss替换成完整路径
$baidu->getHtml('html字符串');
//设置的数据,删除掉oss路径中的域名
$baidu->setHtml('html字符串');