1、编辑器下载:
https://pan.baidu.com/s/1ex3zCVuQsMz8opk75zadPw
2、静态页面中加载 ckeditor.js
<script src="__PUBLIC__/ckeditor/ckeditor.js" type="text/javascript"></script>
3、初始化并添加图片上传
<script>
CKEDITOR.replace('ckeditor',{
filebrowserImageUploadUrl : "{:U('portal/index/uploadimg')}",
language : 'zh-cn',
});
</script>
4、上传代码
$extensions = array("jpg","bmp","gif","png");
$uploadFilename = $_FILES['upload']['name'];
$uploadFilesize = $_FILES['upload']['size']; $extension = pathInfo($uploadFilename,PATHINFO_EXTENSION);
if(in_array($extension,$extensions)){
$uploadPath ="./uploadfile/";
$uuid = date("YmdHis").rand(11111,99999).".".$extension;
$desname = $uploadPath.$uuid;
$previewname = 'domain'.'/uploadfile/'.$uuid;
$tag = move_uploaded_file($_FILES['upload']['tmp_name'],$desname);
$callback = $_REQUEST["CKEditorFuncNum"];
echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction($callback,'$previewname','');</script>";
}else{
echo "文件格式不正确";
}