论坛首页 Web前端技术论坛

发布淘宝开源编辑器 KISSY Editor 1.0.0

浏览 32267 次
该帖已经被评为良好帖
作者 正文
   发表时间:2009-11-10  
我用了下,发现上传图片,只能用链接的,本度上传好像不行阿?
0 请登录后投票
   发表时间:2009-11-18  
哇,确实小巧而强捍,强烈支持!还有一点希望楼主同时把文档跟上:)
0 请登录后投票
   发表时间:2009-11-18   最后修改:2009-11-18


下载下来试用了一下,在使用图片上传功能过程之中,当上传完图片时(后台文件是上传成功的)页面会弹出以下警告:

 

 

对不起,上传文件时发生了错误:

{message => JSON.parse, fileName => http://localhost:8080/send-mail/kissyEditor/editor-aio.js, lineNumber => 2519, stack => ("<pre>[\"0\",\"http://localhost:8080/send-mail/fileUpload/20091118234056.jpg\"]</pre>")@http://localhost:8080/send-mail/kissyEditor/editor-aio.js:2519
([object Object])@http://localhost:8080/send-mail/kissyEditor/editor-aio.js:5030
([object Event],(void 0))@http://localhost:8080/send-mail/kissyEditor/editor-aio.js:3239
([object Event])@http://localhost:8080/send-mail/kissyEditor/editor-aio.js:1654
}
o = {tId => 0, argument => , responseText => <pre>["0","http://localhost:8080/send-mail/fileUpload/20091118234056.jpg"]</pre>, responseXML => {}}
[from upload catch code]
lifesinger 写道

格式,如果成功:

    {"status": "0", "imgUrl": "' . $uri . $filename . '"}

失败:
     {"status": "1", "error": "上传过程中出错了"}

或者直接用数组:

["0", "imgUrl"]

也可以自定义:
new KISSY.Editor {

pluginsConfig: {

    image: {
        upload: {
              formatRespone: function(data) {
                  // data 是服务器返回的 json 数据,格式任意
                  // 你的处理代码
                  // 返回默认格式 ["0", "imgUrl"]  or ["1", "errMsg"]
              }
        }
    }

}

}


最简单的一个 upload.php,测试用:

http://kissy.googlecode.com/svn/trunk/src/editor/demo/upload.php

 

 我在后台action中所返回的两种数据格式都出错了,一种是:["0","http://localhost:8080/send-mail/fileUpload/20091118234056.jpg"] 另一种是:{"status": "0", "imgUrl": "http://localhost:8080/send-mail/fileUpload/20091118234056.jpg"} 不知其因,望Lz给以解决,万谢!

 

 

0 请登录后投票
   发表时间:2009-11-19  
从错误信息里看:

o = {tId => 0, argument => , responseText => <pre>["0","http://localhost:8080/send-mail/fileUpload/20091118234056.jpg"]</pre>, responseXML => {}} 

你返回的是:
<pre>["0","http://localhost:8080/send-mail/fileUpload/20091118234056.jpg"]</pre>

需要去掉 pre
0 请登录后投票
   发表时间:2009-11-19  
lifesinger 写道
从错误信息里看:

o = {tId => 0, argument => , responseText => <pre>["0","http://localhost:8080/send-mail/fileUpload/20091118234056.jpg"]</pre>, responseXML => {}} 

你返回的是:
<pre>["0","http://localhost:8080/send-mail/fileUpload/20091118234056.jpg"]</pre>

需要去掉 pre



我再次检查了一下程序,后台action中所返回的数据["0","http://localhost:8080/send-mail/fileUpload/20091118234056.jpg"],没有加入<pre></pre>标签啊,我是这样输出的:

String content= "[\"0\",\"http://localhost:8080/send-mail/fileUpload/20091118234056.jpg\"]";
response.getWriter().write(content);
response.getWriter().flush();
 

怎么返回到前台会变成 <pre>["0","http://localhost:8080/send-mail/fileUpload/20091118234056.jpg"]</pre>呢?不解?

0 请登录后投票
   发表时间:2009-11-19  
直接将 actionUrl 放浏览器里,查看源码,看是否有 pre
或者用 Firebug 或 Fiddler 工具监控下返回的 raw 数据
0 请登录后投票
   发表时间:2009-11-19   最后修改:2009-11-19
lifesinger 写道
直接将 actionUrl 放浏览器里,查看源码,看是否有 pre
或者用 Firebug 或 Fiddler 工具监控下返回的 raw 数据

 

   我通过Firebug调试之后,D.responseText的值确实是加了多加<pre></pre>标签;但是我再用一个普通的页面进行测试时,同样是调用后台那段程序,但所获得的值却是正常的(没有多加<pre></pre>标签的)从而证明后台程序是没问题的,但不知道是不是我在初始化KISSY.Editor时,pluginsConfig对象哪里没有设置还是什么问题?我是这样初始化的:

<script type="text/javascript">
     KISSY.Editor("demo", {
         pluginsConfig: {
             image: {
                 tabs: ["local", "link"], //"album"],
                 upload: {
                     actionUrl : "ckeditor-image-upload!kissy.action"
                 }
             },
             smiley: {
                 tabs: ["wangwang"]
             }
         }
     });
</script>
 

 

 

0 请登录后投票
   发表时间:2009-11-19  

初始化代码没问题,检查下 返回的 RAW DATA,应该和下面差不多:

 

HTTP/1.1 200 OK
Date: Thu, 19 Nov 2009 13:14:21 GMT
Server: Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i mod_autoindex_color PHP/5.2.8 mod_perl/2.0.4 Perl/v5.10.0
X-Powered-By: PHP/5.2.8
Content-Length: 47
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html

{"status": "0", "imgUrl": "path/to/img"} 

 

注意 Content-Type

0 请登录后投票
   发表时间:2009-11-19   最后修改:2009-11-19
非常感谢lifesinger,问题终于解决了,哎,真不应该,之所以出现问题是我把Content-Type设置成了"text/plain",当把Content-Type设置成"text/html"后一切正常,没问题了.
0 请登录后投票
   发表时间:2009-12-14  
h521999 写道
非常感谢lifesinger,问题终于解决了,哎,真不应该,之所以出现问题是我把Content-Type设置成了"text/plain",当把Content-Type设置成"text/html"后一切正常,没问题了.


你好,请问上传文件时后台获取文件时的parameter是什么?
也就是我们平时在form里:
<input type="file" name="xxx"/>

这个xxx在后台是什么?是imgFile吗?
谢谢!
0 请登录后投票
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics