• .net mvc4 利用 kindeditor 上传本地图片


    http://blog.csdn.net/ycwol/article/details/41824371?utm_source=tuicool&utm_medium=referral

    最近在用kindeditor 编辑器,在上传本地图片的时候遇到了点问题,不能正确的上传。

    现在把使用 kindeditor 上传本地图片的配置记录一下。

    1、下载kindeditor。http://kindeditor.net/down.php

    2、解压,将所有文件复制到项目里。我是放在content里面。

    (您可以根据需求删除以下目录后上传到服务器,asp - ASP程序,asp.net - ASP.NET程序,php - PHP程序,jsp - JSP程序,examples - 演示文件)

    3、将editor/asp.net/bin目录下的dll文件复制到项目bin目录下。

    4、修改HTML页面

    a>添加textarea输入框

    [html] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. <td>@Html.TextAreaFor(a => a.contents, new { id = "editor_id" })</td>  
    2. <!-- 或者<td><textarea id="editor_id" name="contents" >Model.contents</textarea> -->  

    b>在页面添加以下脚本

    [javascript] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. <script charset="utf-8" src="~/content/editor/kindeditor.js"></script>  
    2. <script charset="utf-8" src="~/content/editor/lang/zh_CN.js"></script>  
    3. <script>  
    4.     KindEditor.ready(function (K) {  
    5.         window.editor = K.create('#editor_id', {  
    6.              '600px',  
    7.             height: '400px',  
    8.             items: ['source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'cut', 'copy', 'paste', '|',  
    9.                     'justifyleft', 'justifycenter', 'justifyright', '|',  
    10.                     'insertorderedlist', 'insertunorderedlist', 'clearhtml', 'quickformat', '|',  
    11.                     'anchor', 'link', 'unlink', '|', 'fullscreen', '/',  
    12.                     'formatblock', 'fontname', 'fontsize', '|',  
    13.                     'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'lineheight', 'removeformat', '|',  
    14.                     'image', 'multiimage', 'flash', 'media', 'insertfile', '|',  
    15.                     'table', 'hr', 'emoticons', 'baidumap'],  
    16.   
    17.             //uploadJson: '~/content/editor/asp.net/upload_json.ashx',   //在网上需要配置这句,但是注释了才不报错...只需要下面的  
    18.             fileManagerJson: '~/content/editor/asp.net/file_manager_json.ashx',  
    19.         });  
    20.     });  
    21. </script>  

    如果你改变了 editor 的文件位置,要修改一下 upload_json.ashx 、 file_manager_json.ashx 的保存路径。我的是默认的。

    找到plugins文件夹下的image文件夹,下面有个image.js文件,默认是php的,要修改为asp.net。

    上传本地图片时,路径会显示C:fakepath***,显示fakepath是正常的,出于安全考虑,是无法获取真实路径的。

    最后上效果图:

  • 相关阅读:
    GUI学习笔记之一“Hello world”程序
    GDI和GUI的区别
    Convert.Int32、(int)和int.Parse三者的区别
    华为机试题汇总
    算法导论 第7章 课后习题
    算法导论 第8章 线性时间排序 课后习题
    算法导论 第21章 不相交集合的数据结构
    [转载]NIM(1) 一排石头的游戏
    算法导论 第22章 图论之拓扑排序
    编程珠玑第八章 算法设计艺术
  • 原文地址:https://www.cnblogs.com/zkwarrior/p/5143047.html
Copyright © 2020-2023  润新知