@extends('admin.layouts.master')
{{-- 標(biāo)題 --}}
@section('title', '內(nèi)容管理')
{{-- CSS樣式開(kāi)始 --}}
@section('styles')
<link rel="stylesheet" href="{{ asset('common/css/bootstrap-switch.min.css') }}"> <!-- bootstrap的開(kāi)關(guān)按鈕樣式 -->
<link rel="stylesheet" href="{{ asset('common/css/bootstrap-select.min.css') }}"> <!-- bootstrap的下拉選擇樣式 -->
<link rel="stylesheet" href="{{ asset('editor.md/css/editormd.min.css') }}"> <!-- MD編輯器的樣式 -->
<style type="text/css">
#cover-placeholder {
width: 100%;
height: 300px;
cursor: pointer;
}
</style>
@endsection {{-- CSS樣式結(jié)束 --}}
{{-- 主題內(nèi)容開(kāi)始 --}}
@section('content')
{{-- 內(nèi)容面板開(kāi)始 --}}
<div class="panel panel-default">
{{-- 內(nèi)容標(biāo)題開(kāi)始 --}}
<div class="panel-heading">
<h3 class="panel-title">新建內(nèi)容</h3>
</div> {{-- 內(nèi)容標(biāo)題結(jié)束 --}}
{{-- 內(nèi)容數(shù)據(jù)開(kāi)始 --}}
<div class="panel-body">
{{-- 柵欄開(kāi)始 --}}
<div class="row">
{{-- 柵欄內(nèi)容區(qū)開(kāi)始 --}}
<div class="col-md-12">
{{-- 盒子開(kāi)始 --}}
<div class="box box-solid">
{{-- 表單開(kāi)始 --}}
<form role="form" method="POST" action="{{ url('content') }}" id="page-form">
{{ csrf_field() }}
{{-- 表單提交后, 錯(cuò)誤信息返回 --}}
@include('admin.public.error')
{{-- 盒子內(nèi)容主體開(kāi)始 --}}
<div class="box-body">
<div class="form-group">
<label for="title">頁(yè)面標(biāo)題</label>
<div class="row">
<div class='col-md-6'>
<input type='text' class='form-control' name="title" id='title' placeholder='標(biāo)題'>
</div>
</div>
</div>
<div class="form-group">
<label for="keywords">關(guān)鍵字(Keywords)</label>
<div class="row">
<div class='col-md-6'>
<input type='text' class='form-control' name="keywords" id='keywords' placeholder='請(qǐng)輸入關(guān)鍵字,以#號(hào)分割,利于搜索引擎收錄'>
</div>
</div>
</div>
<div class="form-group">
<label for="cover">封面(Cover)</label>
<div class="row">
<div class='col-md-6'>
 }})
<input type="hidden" name="cover" id="cover" value="{{ asset('admin/content/images/placeholder.jpg') }}">
</div>
</div>
</div>
<div class="form-group">
<label for="content">頁(yè)面內(nèi)容</label>
<div id="editormd">
{{-- MD編輯器左側(cè)編輯開(kāi)始 --}}
<textarea class="editormd-markdown-textarea" style="display:none;" id="content" name="content"></textarea>
{{-- MD編輯器右側(cè)實(shí)時(shí)顯示開(kāi)始 --}}
<textarea style="display:none;" name="html_content"></textarea>
</div>
</div>
</div> {{-- 盒子內(nèi)容主體結(jié)束 --}}
{{-- 盒子底部按鈕組開(kāi)始 --}}
<div class="box-footer">
<button type="submit" id="submit-page" class="btn btn-primary">創(chuàng)建</button>
<button type="reset" id="reset-btn" class="btn btn-warning">重置</button>
</div> {{-- 盒子底部按鈕組結(jié)束 --}}
</form> {{-- 表單結(jié)束 --}}
<!-- 真正的圖片上傳表單 -->
<form id="upload-cover" enctype="multipart/form-data">
<input type="file" name="editormd-image-file" id="editormd-image-file" style="display: none;">
</form>
</div> {{-- 盒子結(jié)束 --}}
</div> {{-- 柵欄內(nèi)容區(qū)結(jié)束 --}}
</div> {{-- 柵欄結(jié)束 --}}
</div> {{-- 內(nèi)容數(shù)據(jù)結(jié)束 --}}
</div> {{-- 內(nèi)容面板結(jié)束 --}}
@endsection {{-- 主題內(nèi)容結(jié)束 --}}
{{-- JS開(kāi)始 --}}
@section('scripts')
<script src="{{ asset('common/js/bootstrap-switch.min.js') }}"></script> <!-- bootstrap的開(kāi)關(guān)按鈕js -->
<script src="{{ asset('common/js/bootstrap-select.min.js') }}"></script> <!-- bootstrap的下拉選擇js -->
<script src="{{ asset('editor.md/editormd.min.js') }}"></script> <!-- MD的js -->
<script src="{{ asset('common/js/MyAjax.js') }}"></script> <!-- 自封裝的ajax -->
<script>
/** 封面圖片上傳 */
$('#cover-placeholder').click(function () {
$('#editormd-image-file').trigger('click');
});
$('#editormd-image-file').change(function () {
$.ajaxSetup({
headers : {
'X-CSRF-TOKEN' : $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
url: '/upload_image',
type: 'POST',
data: new FormData($('#upload-cover')[0]),
cache: false,
processData: false,
contentType: false,
success: function (data) {
$('#cover-placeholder').attr('src', data.url);
$('#cover').val(data.url);
},
error: function(XMLHttpRequest) {
alert('err');
console.log(XMLHttpRequest);
}
});
});
</script>
@endsection {{-- JS結(jié)束 --}}
ajax圖片異步上傳
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- 方法不唯一,這里介紹的是 通過(guò)ajaxSubmit來(lái)完成 ajax對(duì)form表單的提交包括圖片,目的是無(wú)刷新。 -...
- 1.項(xiàng)目中需要圖片的異步上傳,度娘之后發(fā)現(xiàn)有一個(gè)插件可以完成這個(gè)需求,即是:Uploadify 下面是這個(gè)異步上傳...
- 1 簡(jiǎn)介 開(kāi)發(fā)文件上傳功能從來(lái)不是一件愉快的事,異步上傳更是如此,使用過(guò)iframe和Flash的上傳方案,也都感...
- 1. 認(rèn)識(shí)FormData對(duì)象 FormData是Html5新加進(jìn)來(lái)的一個(gè)類(lèi),可以模擬表單數(shù)據(jù) 方法 void a...
- 我難以想象,一個(gè)女孩在深夜遭到陌生男子的突然襲擊,援手明明近在咫尺,卻在長(zhǎng)達(dá)五分鐘后,才得以逃出恐懼的深淵時(shí),是怎...