日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

MVC 中Simditor上传本地图片

發(fā)布時間:2023/12/18 c/c++ 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MVC 中Simditor上传本地图片 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1.引用樣式和js文件

<link href="~/Content/scripts/plugins/simditor/css/simditor.css" rel="stylesheet" /><script src="~/Content/scripts/plugins/simditor/js/simditor.js"></script>

?

2.初始化Simditor

var editor = null;$(function () {//可以參考 http://www.jcodecraeer.com/a/javascript/2015/0201/2393.htmleditor = new Simditor({textarea: $('#NewsContent'),placeholder: '這里輸入公告內(nèi)容...',toolbar: ['title', 'bold', 'italic', 'underline', 'strikethrough', 'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link', 'image', 'hr', '|', 'indent', 'outdent'],upload: {url: '/PublicInfoManage/Notice/SavePic', //文件上傳的接口地址params: null, //鍵值對,指定文件上傳接口的額外參數(shù),上傳的時候隨文件一起提交fileKey: 'fileDataFileName', //服務(wù)器端獲取文件數(shù)據(jù)的參數(shù)名connectionCount: 3,leaveConfirm: '正在上傳文件'}});})

?

upload設(shè)置好就會出現(xiàn)下圖中的選項

實現(xiàn)功能之前需要修改一下引用的js文件,使用查看瀏覽器的審核元素功能查看,發(fā)現(xiàn)input按鈕么有name屬性

3.打開Simditor.js文件搜索accept屬性,然后添加“name=“fileData”屬性,共有兩處需要添加,如下圖

?

4.編寫后臺處理圖片代碼

/// <summary>/// 上傳圖片/// </summary>/// <returns></returns>public ActionResult SavePic(){HttpPostedFileBase file = Request.Files["fileDataFileName"];if (file != null){string strPath = HttpContext.Server.MapPath("/Content/Upload/");if (!Directory.Exists(strPath)){Directory.CreateDirectory(strPath);}string filePath = Path.Combine(strPath, Path.GetFileName(file.FileName));file.SaveAs(filePath);return Success("上傳成功!");}else{return Success("上傳失敗!");}}

?

?

?

來源:http://www.cnblogs.com/ZJ199012/p/6134782.html

?

轉(zhuǎn)載于:https://www.cnblogs.com/youmingkuang/p/6548054.html

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎

總結(jié)

以上是生活随笔為你收集整理的MVC 中Simditor上传本地图片的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。