CKFinder - Quick Upload not passing URL to image Info tab after successful upload

4k views Asked by At

When I use the "Quick Upload" tab to upload a file, the URL is not passed to the "Image Info" tab after a successful upload. If I select OK from the "Quick Upload" after a successful upload, CKFinder switches to the "Image Info" tab, and the following error message "Image source URL is missing" appears. Can anyone shed light on why this might be occurring?

2

There are 2 answers

0
Manjay_TBAG On

Use this code.

In CKEditor config -

config.filebrowserUploadUrl = "/VirtualDirectoryName/ControllerName/ActionName";

Your Action Method

public class ControllerName: Controller
    {
        public ActionResult ActionName(HttpPostedFileBase upload, string CKEditorFuncNum, string CKEditor, string langCode)
        {
            if (upload != null)
            {
                string fileName = Guid.NewGuid() + Path.GetExtension(upload.FileName);

                string basePath = Server.MapPath("~/Uploads");
                upload.SaveAs(basePath + "\\" + fileName);

                string url = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "/Uploads/" + fileName;

                HttpContext.Response.Write("<script>window.parent.CKEDITOR.tools.callFunction(" + CKEditorFuncNum + ", \"" + url + "\");</script>");
                HttpContext.Response.End();
            }

            return View();
        }
    }
0
Hong Van Vit On

It work for me with CKEditor 4. You can try like this:

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();
    }