.net mvc 利用 kindeditor 上傳本地圖片

來源:互聯網
上載者:User

標籤:asp.net   mvc   kindeditor   

最近在用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輸入框

<td>@Html.TextAreaFor(a => a.contents, new { id = "editor_id" })</td><!-- 或者<td><textarea id="editor_id" name="contents" >Model.contents</textarea> -->
b>在頁面添加以下指令碼
    <script charset="utf-8" src="~/content/editor/kindeditor.js"></script>    <script charset="utf-8" src="~/content/editor/lang/zh_CN.js"></script>    <script>        KindEditor.ready(function (K) {            window.editor = K.create('#editor_id', {                width: '600px',                height: '400px',                items: ['source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'cut', 'copy', 'paste', '|',                        'justifyleft', 'justifycenter', 'justifyright', '|',                        'insertorderedlist', 'insertunorderedlist', 'clearhtml', 'quickformat', '|',                        'anchor', 'link', 'unlink', '|', 'fullscreen', '/',                        'formatblock', 'fontname', 'fontsize', '|',                        'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'lineheight', 'removeformat', '|',                        'image', 'multiimage', 'flash', 'media', 'insertfile', '|',                        'table', 'hr', 'emoticons', 'baidumap'],                //uploadJson: '~/content/editor/asp.net/upload_json.ashx',   //在網上需要配置這句,但是注釋了才不報錯...只需要下面的                fileManagerJson: '~/content/editor/asp.net/file_manager_json.ashx',            });        });    </script>

如果你改變了 editor 的檔案位置,要修改一下 upload_json.ashx 、 file_manager_json.ashx 的儲存路徑。我的是預設的。

找到plugins檔案夾下的image檔案夾,下面有個image.js檔案,預設是php的,要修改為asp.net。


上傳本地圖片時,路徑會顯示C:\fakepath\***,顯示fakepath是正常的,出於安全考慮,是無法擷取真實路徑的。

最後上:


.net mvc 利用 kindeditor 上傳本地圖片

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.