又拍 UpYun 云存储百度编辑器 UEditor 集成工具 安装使用手册 v0.2 2013.01
目录 一 使用须知 :... 3 二 安装说明 :... 4 三 联系我们 :... 6 附一 : 百度编辑器 UEditor 完整版部署与体验 :... 7 附二 此集成工具所做的一些修改 :... 9 杭州纬聚网络有限公司 2 / 11
一 使用须知 : 已经安装部署百度编辑器 UEditor 工具是基于又拍云存储服务的, 使用需要有有效的又拍云存储帐号, 还没有帐号的用户, 可前往又拍 云存储官网免费申请全功能体验帐号 :https:/// 杭州纬聚网络有限公司 3 / 11
二 安装说明 : 1. 官网下载工具包 upyun_ueditor.zip; 2. 解压到任意目录, 可得文件夹 upyun-ueditor; 3. 复制文件 upyun-ueditor/upyun_config.php upyun-ueditor/upyun.class.php upyun-ueditor/editor_config.js upyun-ueditor/index.php 到所部署的 UEditor 根目录下, 复制文件 upyun-ueditor/php/fileup.php upyun-ueditor/php/imageup.php 到所部署的 UEditor 根目录下的 php 目录 ; 4. 配置 upyun-ueditor/upyun_config.php 中的又拍云存储空间授权信息 //upyun 图片空间授权 $img_bucketname = ""; // 图片空间名称 $img_username = ""; // 图片空间授权管理员帐号 $img_password = ""; // 图片空间授权管理员密码 //upyun 文件空间授权 $file_bucketname = ""; // 文件空间名称 $file_username = ""; // 文件空间授权管理员帐号 $file_password = ""; // 文件空间授权管理员密码 说明 : 如果不需要将图片和非图片类文件分空间存储, 则只需将图片空间和文件空间相关信息填 写成同一个文件类空间即可 ( 必须为文件类空间 ) 5. 配置 upyun-ueditor/editor_config.js 中的空间名 var img_bucketname = ""; //upyun 图片空间名 var file_bucketname = ""; //upyun 文件空间名 杭州纬聚网络有限公司 4 / 11
说明 : 如果不需要将图片和非图片类文件分空间存储, 则只需将图片空间和文件空间相关信息填 写成同一个文件类空间即可 ( 必须为文件类空间 ) 杭州纬聚网络有限公司 5 / 11
三 联系我们 : 插件相关反馈请邮件联系 : faq@upyun.com 我们会在最短的时间内尽量给您满意的答复 ~~ 杭州纬聚网络有限公司 6 / 11
附一 : 百度编辑器 UEditor 完整版部署与体验 : 方法一 : 1 将解压所得文件夹 upyun-ueditor 直接拷贝到项目 2 访问 upyun-ueditor 下的 index.php 方法二 : 1 从百度官网 (http://ueditor.baidu.com/website/) 下载完整源码包, 并解压 2 在项目根目录下创建目录 upyun-ueditor 用于存放 UEditor 相关资源和文件 3 拷贝源码包中的 dialogs lang php _src themes third-party editor_all_min.js editor_config.js 到 upyun-ueditor 目录 4 在 upyun-ueditor 目录下创建 index.php 页面作为编辑器的实例化页面, 用来展示 UEditor 的完整版 效果 显示代码如下 : <html> <head> <meta http-equiv='content-type' content='text/html;charset=utf-8' /> <title>upyun UEditor</title> <script type='text/javascript' src='editor_config.js'></script> <script type='text/javascript' src='editor_all.js'></script> </head> <body> <textarea name=" 后台取值的 key" id="myeditor"> 这里写你的初始化内容 </textarea> 杭州纬聚网络有限公司 7 / 11
<script type='text/javascript'> var editor = new UE.ui.Editor(); editor.render('myeditor'); </script> </body> </html> 5 在 upyun-ueditor/editor_config.js 中查找 URL 变量, 配置编辑器在你项目中的路径 URL = window.ueditor_home_url / 项目目录 /upyun-ueditor/ ; 6 附件存储路径必须存在并且有写的权限, 默认路径是 upyun-ueditor/php/upload/, 不存在, 需创建 至此, 一个完整的编辑器实例就已经部署好了, 可以访问 index.php 页面查看效果 注意 : 在引用 editor_config.js 时, 最好先于 editor_all.js 加载, 否则特定情况下可能会出现报错 ; 杭州纬聚网络有限公司 8 / 11
附二 此集成工具所做的一些修改 : 1 在原有文件的基础上添加了文件 upyun-ueditor/upyun.class.php upyun-ueditor/upyun_config.php 2 修改的文件有 upyun-ueditor/editor_config.js upyun-ueditor/php/imageup.php upyun-ueditor/php/fileup.php 3 保证文件夹 upyun-ueditor/php 有写的权限, 在此文件夹程序会自动创建错误日志 针对文件 upyun-ueditor/editor_config.js 在 var URL; 下方添加 : var img_bucketname = ""; //upyun 图片空间名 var file_bucketname = ""; //upyun 文件空间名 修改,imagePath:URL + "php/" 为 :,imagepath:"http://" + img_bucketname + ".b0.upaiyun.com/" 修改,filePath:URL + "php/" 为 :,filepath:"http://" + file_bucketname + ".b0.upaiyun.com/" 针对文件 upyun-ueditor/php/imageup.php 在 include "Uploader.class.php"; 下方添加 : include "../upyun.class.php"; include "../upyun_config.php"; 在 $info = $up->getfileinfo(); 下方添加 : $upyun = new UpYun($img_bucketname, $img_username, $img_password); 杭州纬聚网络有限公司 9 / 11
try { $con = $info["url"]; $opts = array( UpYun::CONTENT_MD5 => md5(file_get_contents($con)) ); $fh = fopen($con, "rb"); $rsp = $upyun->writefile("/".$con, $fh, True, $opts); // 上传图片, 自动创建目录 fclose($fh); } catch(exception $e) { $filename = "error_log.txt"; $errorcontent = "image ". date("y-m-d H:m:s"). " ". $e->getcode()." ". $e->getmessage(). "\r\n"; $handle = fopen($filename, 'a'); fwrite($handle, $errorcontent); fclose($handle); exit; } 针对文件 upyun-ueditor/php/fileup.php 在 include "Uploader.class.php"; 下方添加 : include "../upyun.class.php"; include "../upyun_config.php"; 杭州纬聚网络有限公司 10 / 11
在 $info = $up->getfileinfo(); 下方添加 : $upyun = new UpYun($file_bucketname, $file_username, $file_password); try { $con = $info["url"]; $opts = array( UpYun::CONTENT_MD5 => md5(file_get_contents($con)) ); $fh = fopen($con, "rb"); $rsp = $upyun->writefile("/".$con, $fh, True, $opts); // 上传图片, 自动创建目录 fclose($fh); } catch (Exception $e) { $filename = "error_log.txt"; $errorcontent = "file ". date("y-m-d H:m:s"). " ". $e->getcode()." ". $e->getmessage(). "\r\n"; $handle = fopen($filename, 'a'); fwrite($handle, $errorcontent); fclose($handle); exit; } 杭州纬聚网络有限公司 11 / 11