CKeditor:从数据库而不是服务器/ web上传图像

时间:2012-06-29 16:13:32

标签: asp.net-mvc-3 ckeditor

我正在尝试在我的MVC 3项目中使用CKeditor。我的问题是:我想不想从服务器/网络上传图像。我想为此目的使用我自己的数据库。请告诉我如何将图像上传器导入我的数据库或说我的本地机器。我是MVC& CKeditor,不知道如何进一步。

提前致谢!!

我的观点如下:

  

<%= Html.LabelFor(model => model.Description)%>

     

<%= Html.TextAreaFor(model => model.Description,new {@class> =“ckeditor”})%>

<%= Html.ValidationMessageFor(model => model.Description) %>

</div>

<script type="text/javascript">
CKEDITOR.replace('Description', {

filebrowserImageUploadUrl: '/UploadImage'

});

</script>

我的控制器是这样的:

public ActionResult UploadImage(HttpPostedFileBase upload,string CKEditorFuncNum,      string CKEditor, string langCode) 
    {
        string url; // url to return
        string message; // message to display (optional) 

    // here logic to upload image
    // and get file path of the image

   // path of the image

     string path = "Content/Images/my_uploaded_image.jpg";



   // will create http://localhost:1457/Content/Images/my_uploaded_image.jpg

   url = Request.Url.GetLeftPart(UriPartial.Authority) +"/"+ path;



  // passing message success/failure

      message = "Image was saved correctly";



    string output = @"<html><body>   <script>window.parent.CKEDITOR.tools.callFunction("+CKEditorFuncNum+", \""+url+"\", \""+message+"\");</script></body></html>";

     return Content(output);       
          }

0 个答案:

没有答案