Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 412
RHPT Avatar asked Dec 17 '13 03:12

RHPT


People also ask

What does image source URL missing mean?

The "Image Source URL Is Missing" error message seems to indicate that the uploader isn't passing the URL to CKEditor in a way that CKEditor can understand it. This page in the Developers Guide explains how to pass the the URL to CKEditor: Integrating CKEditor with a Custom File Browser.

How do I change my Ckfinder upload path?

Startup path was designed to work when browsing files. To set a different folder for the QuickUpload command, use "currentFolder" attribute: filebrowserImageUploadUrl : '/ckfinder/core/connector/php/connector.

How do I upload an image using CKEditor?

To upload a new image open the upload panel in the image browser. Open the Image info tab and click Browse server. A new window will open where you see all your uploaded images. Open the Settings to choose another upload path.


1 Answers

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();
        }
    }
like image 183
Manjay_TBAG Avatar answered Oct 28 '22 13:10

Manjay_TBAG