尝试在asp.net中的MVC 5中配置CKEditor。 在视图中:
@Html.TextBoxFor(model => model.Title, new { @class = "form-control" })
<script type="text/javascript">
CKEDITOR.replace('editor1', {
filebrowserBrowseUrl: '@Url.Action("UploadImage","Administrator")',
filebrowserUploadUrl: '@Url.Action("uploadnow", "Administrator")'
});
</script>
我的控制器在哪里
public void uploadnow(HttpPostedFileWrapper upload)
{
if (upload != null)
{
string ImageName = upload.FileName;
string path = System.IO.Path.Combine(Server.MapPath("~/Images/uploads"), ImageName);
upload.SaveAs(path);
}
}
此代码工作正常。 另一个动作是:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult UploadImage(HttpPostedFileBase upload, string CKEditorFuncNum, string CKEditor, string langCode)
{
string url; // url to return
string message; // message to display (optional)
message = "Image successfully saved ";
//do save image code here
url = "/" + Server.MapPath("~/Images/uploads") + "/" + upload.FileName;
string output = @"<html><body><script>window.parent.CKEDITOR.tools.callFunction(" + CKEditorFuncNum + ", \"" + url + "\", \"" + message + "\");</script></body></html>";
return Content(output);}
我可以在"Browse Server"
标签下看到Image info
按钮。还可以添加Upload
标签。其中,在选择图像后的“上载”窗口中,它将保存到指定位置,但显示空白窗口而不预览文本"Send it to the Server"
。如果我点击“确定”按钮,则会显示Image source URL is missing.
错误消息。需要纠正的是什么?