select2:'component/select2', <script> require(['select2'],function (b) { b('.select2'); }); </script> define([ 'package/select2.min', 'css!package/css/select2.min.css' ], function () { return function (el) { return $(el).select2(); } })
419 認證超時 並非HTTP標註的一部分,419認證超時表示之前的有效證實已經失效了。同時也被用於401未認證的替代選擇爲了從其 它被拒絕訪問的已認證客戶端中指定服務器的資源。 緣由是由於在lavarel中使用hdjs上傳圖片忘記加csrf-token驗證了 <meta name="csrf-token" content="{{csrf_token()}}">
/** *傳提供選擇以往上傳文件的功能,後臺須要返回文件列表數據 * 獲取已經上傳圖片數據 * @return array */ public function filesLists(){ $files = glob('uploadImages/*/*'); foreach ($files as $f) { $file = asset($f); $data[] = [ 'url' => $file, 'path' => $file, 'size' => filesize($f), 'name' => basename($f), 'createtime' => date('Y-m-d', filemtime($f)), ]; } return ['data' => $data,'code'=>0, 'page' => []]; }
例子 1 <?php print_r(glob("*.txt")); ?> 輸出相似: Array ( [0] => target.txt [1] => source.txt [2] => test.txt [3] => test2.txt )
define(['component/fileUploader', 'hdjs'], function (fileUploader, hdjs) { return function (callback, options) { //初始化參數數據mes options = options ? options : {}; //初始化POST數據 options.data = options.data ? options.data : {}; let opts = $.extend({ width: hdjs.isMobile() ? '95%' : 800,//寬度 type: 'image', extensions: 'gif,jpg,jpeg,png', multiple: false, fileSizeLimit: 200 * 1024 * 1024, fileSingleSizeLimit: 2 * 1024 * 1024, compress: false, data: {}, //後臺上傳處理地址 uploader: '' }, options); fileUploader.show(function (images) { if (images.length > 0) { if ($.isFunction(callback)) { callback(images); } } }, opts); } })