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?
-
Are you using CKFinder or your own uploader?– AlfonsoMLCommented Jan 21, 2014 at 21:11
-
I am using CKFinder's uploader– RHPTCommented Jan 21, 2014 at 21:25
-
Then you should ask their support team, it doesn't seem that SO is the correct place for your question.– AlfonsoMLCommented Jan 22, 2014 at 14:56
Add a comment
|
2 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();
}
}
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();
}