您当前的位置: 首页 > 学无止境 > 心得笔记 网站首页心得笔记
thinkphp3.2.3学习笔记-百度UE后端配置
发布时间:2018-05-09 13:06:19编辑:雪饮阅读()
修改百度ue编辑器默认上传图片路径:
在路径"/ueditor1_4_3_2-utf8-php/utf8-php/php"下的config.json文件中”上传图片配置项”的"imagePathFormat"项就负责配置ue编辑器默认上传图片路径,这有注释说明修改规则,按照规则就可以修改成你的自定义路径。
使用thinkphp3.2.3的文件上传类:
前端:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
input{
width:100%;
}
</style>
<!--加载ue配置文件-->
<script type="text/javascript" src="/ueditor1_4_3_2-utf8-php/utf8-php/ueditor.config.js">
</script>
<!--加载编辑器源码文件-->
<script type="text/javascript" src="/ueditor1_4_3_2-utf8-php/utf8-php/ueditor.all.js">
</script>
<title>{$title}</title>
</head>
<body>
<!--实例化编辑器-->
<script type="text/javascript">
var ue=UE.getEditor("container");
</script>
<form action="{:U('Index/addArticleLogic')}" method="post" enctype="multipart/form-data">
<p>封面图片:<input type="file" name="coverImg"></p>
<textarea id="container"></textarea>
<input type="submit" value="提交" />
</form>
</body>
</html>
后端:
<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
public function index(){}
public function addArticleView(){
$this->title="文章添加";
$this->display();
}
public function addArticleLogic(){
//实例化上传类
$upload=new \Think\Upload();
//设置附件上传大小
$upload->maxSize=3145728;
//设置附件上传类型
$upload->exts=array('jpg','gif','png','jpeg');
//设置附件上传根目录
$upload->rootPath='./Public/';
//设置附件上传子目录
$upload->savePath='upload/coverImg/';
//上传文件
$info=$upload->upload();
if(!$info){
$this->error($upload->getError());
exit();
}
echo "upload Success<br/>";
echo "<pre>";
print_r($info);
echo "</pre>";
}
}
关键字词:thinkphp,ue