Seven Cow cloud: CKEditor JS SDK combined with C # to achieve multi-image upload.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.