老師,您好,我用tp6框架引入wangeditor,但是無法把編輯內容的值傳給後端,能幫忙分析下嗎?
html:
<form class="form-horizontal" role="form" enctype="multipart/form-data" method="post" action="/index.php /admin/article/artadd"> <div class="form-group"> <label for="title" class="col-sm-2 control-label">標題</label> < ;div class="col-sm-10"> <input type="text" class="form-control" id="title" name="title" placeholder="請輸入標題" > </ div> </div>
<div id="editor—wrapper" name="content"> <div id="toolbar-container" ><!-- 工具列- -></div> <div id="editor-container" > <!-- 編輯器--></div> </div> <div class="col-md; -2 col-md-offset-9"> <button type="submit" class="btn btn-default" style="float: right;" onclick="save();">存檔</ button> </div> </form>
js程式碼
function save(){ var data = new Object; data.content = editor /tml(); (content =='') {} $.post('/index.php/admin/article/artadd',data,function(res){ },'json'); alert(data.content); }
後端程式碼
public function artadd(){ //加上判斷,讓兩個不同時執行 if (Request::isPost()) { = if (Request::isPost()) { = input('post.title'); $cid = input('post.cid'); $time = time(); )); $status = input('post.status'); $hot = input('post.hot'); $himg = input('post.himg') $himg = input('post.himg') ; // $picurl = input('post.picurl'); // 取得表單上傳檔案例如上傳了001.jpg $file = request()-url> pic $file = request()-url; $file)){ $savename = \think\facade\Filesystem::putFile( 'topic', $file); 'msg'=> ;'上傳圖片失敗']); // } $insert = Db::table('yzt_article')->insert 'content ' =>$content, 'hot' => $hot, 'himg' => $himg, 'cimg' => $himg, 'cimg' => $himg, 'cimg' => $himg, 'cimg' => $himg, ” 'status'=>$ status, 'time' =>$time ]);
network中看一下請求