1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > Ueditor HTML编辑器图片上传路径修改(php版)

Ueditor HTML编辑器图片上传路径修改(php版)

时间:2020-10-07 01:59:16

相关推荐

Ueditor HTML编辑器图片上传路径修改(php版)

1.ueditor.config.js

修改文件里面图片的上传路径。把imagePath设置为空。前面的URL去掉

var URL = window.UEDITOR_HOME_URL || getUEBasePath();/*** 配置项主体。注意,此处所有涉及到路径的配置别遗漏URL变量。*/window.UEDITOR_CONFIG = {//为编辑器实例添加一个路径,这个不能被注释UEDITOR_HOME_URL : URL//图片上传配置区,imageUrl:URL+"php/imageUp.php" //图片上传提交地址,imagePath:"" //图片修正地址,引用了fixedImagePath,如有特殊需求,可自行配置//,imageFieldName:"upfile" //图片数据的key,若此处修改,需要在后台对应文件修改对应参数

在toolbars中添加insertimage,图片上传的图标

//工具栏上的所有的功能按钮和下拉框,可以在new编辑器的实例时选择自己需要的从新定义, toolbars:[['fullscreen', 'source', '|', 'undo', 'redo', '|','bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|','rowspacingtop', 'rowspacingbottom', 'lineheight', '|','customstyle', 'paragraph', 'fontfamily', 'fontsize', '|','directionalityltr', 'directionalityrtl', 'indent', '|','justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|','link', 'unlink','insertimage']]

2. 打开PHP目录里面有一个config.php ,imageUP.php是调用这里面的路径,也可以直接修改imageUp.php

<?phpreturn array(//图片上传允许的存储目录'imageSavePath' => array ('../../upload/img'));

或者修改imageUP.php的这边也可以

//获取存储目录if ( isset( $_GET[ 'fetch' ] ) ) {header( 'Content-Type: text/javascript' );echo 'updateSavePath('. json_encode($imgSavePathConfig) .');';return;}//上传配置$config = array("savePath" => $imgSavePathConfig,"maxSize" => 1000, //单位KB"allowFiles" => array(".gif", ".png", ".jpg", ".jpeg", ".bmp"));if ( empty( $path ) ) {$path = $config[ 'savePath' ][ 0 ];}

3.路径问题

我填写的“../../upload/img” 这个路径是绝对路径,是根据当前php目录定位到你项目的上传目录。

4.上传失败后,可以根据调试工具调整自己的路径

注意:linux上传注意目录权限。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。