1. 程式人生 > >KindEditor檔案上傳

KindEditor檔案上傳

選擇程式語言

// ASP
KindEditor.ready(function(K) {
        K.create('#textarea_id', {
                uploadJson : '../asp/upload_json.asp',
                fileManagerJson : '../asp/file_manager_json.asp',
                allowFileManager : true
        });
});
// ASP.NET
KindEditor.ready(function(K) {
        K.create('#textarea_id', {
                uploadJson : '../asp.net/upload_json.ashx',
                fileManagerJson : '../asp.net/file_manager_json.ashx',
                allowFileManager : true
        });
});
// JSP
KindEditor.ready(function(K) {
        K.create('#textarea_id', {
                uploadJson : '../jsp/upload_json.jsp',
                fileManagerJson : '../jsp/file_manager_json.jsp',
                allowFileManager : true
        });
});

POST引數

  • imgFile: 檔案form名稱
  • dir: 上傳型別,分別為image、flash、media、file

返回格式(JSON)

//成功時
{
        "error" : 0,
        "url" : "http://www.example.com/path/to/file.ext"
}
//失敗時
{
        "error" : 1,
        "message" : "錯誤資訊"
}