参考ます。https://www.cnblogs.com/Scholars/p/8968838.html
ダウンロード:http://www.wangeditor.com/
フロントエンドのコード:
<スクリプトタイプの= 「テキスト/ JavaScriptを」 > // スクリプトの2行をされて、次のポップアップテキストボックス のvar E = window.wangEditorの VARのエディタ= 新しい新しい E(「#editor 」) // (たとえば)写真をアップロード editor.customConfig.uploadImgServer = ' /upload.ashx ' // ネットワークの写真を隠す editor.customConfig.showLinkImg = falseを // タイムアウト時間が変更された3S editor.customConfig.uploadImgTimeout = 1000年 * 10 ; のdocument.getElementById(' BTN1 ').addEventListener(' クリック' 、機能(){ // 读取htmlの 警告(editor.txt.html()) }、偽) editor.create(); </ SCRIPT> <body> <フォームID = " newspost "メソッド= " ポスト"アクション= " newspost "のenctype = " マルチパート/フォームデータ" > の<input type = " 隠れた" ID = " コンテンツ" NAME = " <DIVスタイル= " パディング:5pxの0;色:#CCC " > </ div> <DIV ID = " 編集" > </ div> <BR/> </ FORM> <ボタンID = " BTN1 " >获取HTML </ボタン> </ BODY>
バックエンドのコード(通常はハンドラ):
使用してシステムを。 使用してSystem.Collections.Genericを。 使用してSystem.IOを。 使用してSystem.Linqのを。 使用してのSystem.Webを。 名前空間WebApplication1と { /// <要約> /// アップロード的摘要说明 /// </要約> パブリック クラスのアップロード:IHTTPハンドラ { 公共 空のprocessRequest(のHttpContextコンテキスト) { context.Response.ContentType = " text / plainの" ; context.Response.Charset = " UTF-8" ; VARファイル=のcontext.Request.Files; もし(files.Count <= 0 ) { リターン; } HttpPostedFileファイル =ファイル[ 0 ]; 場合(ファイル== NULL ) { context.Response.Write(" エラー|ファイルヌルである" ); を返す; } 他 { 文字列のURL = " http://192.168.0.20:8099/IMG/ " 、 文字列パス= context.Server.MapPath(" / Upader / IMG / ")。 // 存储图片的文件夹 場合(!Directory.Exists(パス)) { Directory.CreateDirectory(パス); } ストリング originalFileName = file.FileName。 ストリング fileExtension = originalFileName.Substring(originalFileName.LastIndexOf(' ')、originalFileName.Length - originalFileName.LastIndexOf(' ' )); 文字列 currentFileName =(新しいランダム())次()+ fileExtension。 ; // 画像に戻るURL context.Response.Write(JSON); リターン; } } パブリック BOOL IsReusableは { GET { 返す falseに; } } } } 通常ハンドラのコード