上传文件


KindEditor默认提供ASP、ASP.NET、PHP、JSP上传程序,这些程序是演示程序,建议不要直接在实际项目中使用。 如果您确定直接使用本程序,使用之前请仔细确认相关安全设置。

选择程序语言¶

  1. // ASP
  2. KindEditor.ready(function(K) {
  3. K.create('#textarea_id', {
  4. uploadJson : '../asp/upload_json.asp',
  5. fileManagerJson : '../asp/file_manager_json.asp',
  6. allowFileManager : true
  7. });
  8. });
  9. // ASP.NET
  10. KindEditor.ready(function(K) {
  11. K.create('#textarea_id', {
  12. uploadJson : '../asp.net/upload_json.ashx',
  13. fileManagerJson : '../asp.net/file_manager_json.ashx',
  14. allowFileManager : true
  15. });
  16. });
  17. // JSP
  18. KindEditor.ready(function(K) {
  19. K.create('#textarea_id', {
  20. uploadJson : '../jsp/upload_json.jsp',
  21. fileManagerJson : '../jsp/file_manager_json.jsp',
  22. allowFileManager : true
  23. });
  24. });

Note

具体使用方法请参见各语言(asp、asp.net、php、jsp)目录下的demo.xxx文件。

POST参数¶

  • imgFile: 文件form名称
  • dir: 上传类型,分别为image、flash、media、file

返回格式(JSON)¶

  1. //成功时
  2. {
  3. "error" : 0,
  4. "url" : "http://www.example.com/path/to/file.ext"
  5. }
  6. //失败时
  7. {
  8. "error" : 1,
  9. "message" : "错误信息"
  10. }