开发者

Image uploading using CKEditor in asp.net mvc

I am using CKEditor in my application as rich text box. It is used to provide bullets and numbering. Now we need to upload images in between the text. So how can i accomplish开发者_高级运维 this? What all configuraion is to be set? Also should i use CKFinder for this? If so please detail me on this.


You can try like this:

In view.

filebrowserImageUploadUrl: '../../Upload/uploadnow'

In Controller

public ActionResult uploadnow(HttpPostedFileWrapper upload, string CKEditorFuncNum)
    {
        string path = "";
        string pathWeb ="";
        if (upload != null)
        {
            string ImageName = upload.FileName;
            string extention = Path.GetExtension(ImageName);
            string name = DateTime.Now.ToString("yyMMddhhmmssms");
            ImageName = name + extention;
            pathWeb = "/images/uploads/" + ImageName;
            path = System.IO.Path.Combine(Server.MapPath("~/images/uploads"), ImageName);
            upload.SaveAs(path);
            HttpContext.Response.Write("<script>window.parent.CKEDITOR.tools.callFunction(" + CKEditorFuncNum + ", \"" + pathWeb + "\");</script>");
            HttpContext.Response.End();
        }
        return View();
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜