CKFinder - 成功上传后,快速上传不会将URL传递到图像信息选项卡

时间:2013-12-17 03:43:59

标签: ckeditor ckfinder

当我使用“快速上传”标签上传文件时,成功上传后,网址不会传递到“图片信息”标签。如果我在成功上传后从“快速上传”中选择确定,CKFinder将切换到“图像信息”选项卡,并显示以下错误消息“图像源URL丢失”。任何人都可以阐明为什么会发生这种情况吗?

2 个答案:

答案 0 :(得分:1)

使用此代码。

在CKEditor配置中 -

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

您的行动方法

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

答案 1 :(得分:0)

它适用于CKEditor 4.您可以尝试这样:

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