最近一段时间比较忙,今天偶然用到富文本编辑器,我一般喜欢用最新版本的,看了下和以前的ueditor修改的比较多,今天时间不多,没有做成一个完整版本的,就给大家展示修改哪里可以

./php/getToken.php

<?php
/*
* @description   文件上传方法
* @author widuu  http://yun.widuu.com
* @mktime 09/10/2014
*/
header("Content-type:text/html;charset=utf-8");

$accessKey = "your accessKey";
$secretKey = "your secretKey";

$bucket = "你的bucket";

$host  = "你的七牛访问地址,譬如xxx.u.qiniudn.com";

$time = time()+3600;

if(empty($_GET["key"])){
    exit('param error');
}else{
    $data =  array(
            "scope"=>$bucket.":".$_GET['key'],
            "deadline"=>$time,
            "returnBody"=>"{\"url\":\"{$host}$(key)\", \"state\": \"SUCCESS\", \"name\": $(fname),\"size\": \"$(fsize)\",\"w\": \"$(imageInfo.width)\",\"h\": \"$(imageInfo.height)\"}"
        );
}

$data = json_encode($data);
$find = array('+', '/');
$replace = array('-', '_');
$data = str_replace($find, $replace, base64_encode($data));
$sign = hash_hmac('sha1', $data, $secretKey, true);
$result = $accessKey . ':' . str_replace($find, $replace, base64_encode($sign)).':'.$data ;
echo $result;

./php/config.json

"imageActionName": "uploadimage", /* 执行上传图片的action名称 */
"imageUrl":"http://upload.qiniu.com/",
"imageFieldName": "file", /* 提交的图片表单名称 */

./dialogs/image/image.js

uploader.on('uploadBeforeSend', function (file, data, header) {
            //这里可以通过data对象添加POST参数
            header['X_Requested_With'] = 'XMLHttpRequest';
});

修改成

uploader.on('uploadBeforeSend', function (file, data, header) {
            //这里可以通过data对象添加POST参数
            header['X_Requested_With'] = 'XMLHttpRequest';
            data['key']= file.file.name;
            var filename = file.file.name;
            var token ="";
            $.ajax({
                        dataType:'text',
                        async:false,
                        url:"../../php/getToken.php?key="+filename,
                        success:function(data) {
                            token = data;
                        }
            });
            data['token'] = token;
        });

然后将其中的

 uploader.option('server', url);

修改成

 uploader.option('server', editor.getOpt('imageUrl'));
112

点赞(30) 打赏

评论列表 共有 0 条评论

暂无评论

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部