博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
.net mvc4 利用 kindeditor 上传本地图片
阅读量:7173 次
发布时间:2019-06-29

本文共 1766 字,大约阅读时间需要 5 分钟。

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]   
 
 
  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]   
 
 
  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.             width: '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是正常的,出于安全考虑,是无法获取真实路径的。

最后上效果图:

你可能感兴趣的文章
Objective-C类的使用
查看>>
IE无法打开internet网站已终止操作的解决的方法
查看>>
基于jQuery商品分类选择提交表单代码
查看>>
解读ASP.NET 5 & MVC6系列(4):核心技术与环境配置
查看>>
CDT+Eclipse代码自动提示
查看>>
shell 下执行mysql 命令
查看>>
[PHP] - PDO事务操作
查看>>
完美解决VMware Workstation : Could not open /dev/vmmon: No such file or directory
查看>>
SharePoint 2010用“localhost”方式访问网站,File not found问题处理方式
查看>>
【转】安卓手机有安全模式?安卓4.1安全模式介绍
查看>>
利用bat批处理做启动mongodb脚本
查看>>
C#中一道关于多线程的基础练习题——模拟仓库存销过程
查看>>
杭州驾校模拟考试
查看>>
qmake的使用
查看>>
MySql 命令行
查看>>
浅谈移动端开发页面
查看>>
让你提前知道软件开发(24):C语言和主要特征的历史
查看>>
启动weblogic11g一直提示<141281> <unable to get file lock, will retry ...>
查看>>
UVA 12898 And Or 数学暴力
查看>>
Windows 8(虚拟机环境)安装.NET Framework3.5(includes .NET 2.0 and 3.0)
查看>>