It's been a success, for 2 days. Share your experience.
The first is to download the official example, and then modify it as follows.
Where Tempvalue is a global variable.
function Savetoqiniu () {var uploader = Qiniu.uploader ({runtimes: "Html5,flash,html4", Browse_button: "Setfile", Save_ke Y:false,//uptoken:qiniu_uptoken,get_new_uptoken:true,uptoken_func:function () {tempvalue=getfileinfo (); var res = $.ajax ({type: "Get", data: {key:tempvalue}, url: "/goods/ckeditorgetu ploadtoken/", async:false}); Return Json.parse (Res.responsetext). Uptoken;},//uptoken_url: "/goods/ckeditorgetuploadtoken?key=" + TempValue, Domain:qiniu_bucket_domain,container: "Container", max_file_size: "6MB", filters: {mime_types: [{title: "Image Files", Extensions: "Jpeg,jpg,gif,png,wbmp"}]},flash_swf_url: "./moxie.swf", Max_retries:3,dragdrop:true,drop_element: " Container ", Chunk_size:" 4MB ", Auto_start:false,init: {" Postinit ": function () {document.getElementById (" UploadFile ") . onclick = function () {//document.getelementbyid ("Setfile"). Style.display = "None"; Uploader.start (); return false}}, " Filesadded ": function (UP, FIles) {Plupload.each (files,function (file) {document.getElementById ("FileInfo"). InnerHTML + = ' <div id= ' + file.id + ' > ' + file.name + ' ("+ plupload.formatsize (file.size) +") & Lt;b></b><i></i></div><br> "; var key = Math.Round (new Date (). GetTime ()/+) + "_" + file.name; Keyqiniuupload = key; Test2 ();})}, "Beforeupload": function (up, file) {}, ' uploadprogress ': function (up, file) {Document.getelement Byid (file.id). getElementsByTagName ("B") [0].innerhtml = "<span>" + file.percent + "%</span>"}, " Fileuploaded ": function (up, file, info) {var res = Json.parse (info); var sourcelink = Qiniu_bucket_domain +"/"+ res.key;d Ocument.getelementbyid (file.id). getElementsByTagName ("i") [0].innerhtml = Sourcelink;window. CKEDITOR.tools.callFunction (1, sourcelink, ' OK ');}, "Error": function (up, err, Errtip) {}, "Uploadcomplete": function () {}, "Key": function (up, file) {var key = Tempvalue;console.log (up); return key;}});}
Also note that key to the background to go, each time the key is different. The following is the C # code.
<summary>/// get CKEditor Upload voucher///</summary>// <returns></returns> Public ActionResult Ckeditorgetuploadtoken (string key) { string s= uploadutil.getuploadtoken ("Kmsfan", key); if (!string. IsNullOrEmpty (s)) { token token1 = new token (); Token1.uptoken = s; s = jsonconvert.serializeobject (TOKEN1); HttpContext.Response.ContentType = "Text/plain"; return Content (s); Return Json (New {Uptoken = s}); } Return Json (New {issuccess = false}); }
Online has not found a similar solution, I this person is not very good at expression, if necessary, do not understand, please leave a message at the bottom.
Seven Cow cloud: CKEditor JS SDK combined with C # to achieve multi-image upload.