<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                異步上傳圖片的方法,沒有直接做成單獨的插件。他集成在 layui 里面的,因此我們直接通過下載 layui 即可。官網:[http://www.layui.com/](http://www.layui.com/),下載文件,解壓到 public 中: ![](https://box.kancloud.cn/5005082d641864e3cb33f582f80dc2d1_229x282.png) 新建 application\\index\\controller\\Layer.php ~~~ <?php namespace app\index\controller; use think\Controller; class Layer extends Controller { // 顯示上傳頁面 public function upload() { return $this->fetch(); } } ~~~ 新建 application\\index\\view\\layer\\upload.html ~~~ <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>上傳插件</title> <link href="/static/layui/css/layui.css" rel="stylesheet"> </head> <body> <div style="margin: 50px 50px"> <!-- 上傳文件 --> <input type="file" name="up_file" class="layui-upload-file"> <div id="yl"></div> </div> <script src="/static/layui/layui.js"></script> <script> layui.use('upload', function() { var $ = layui.jquery; layui.upload({ url: "{:url('layer/doupload')}" , ext: 'jpg|png|gif' //那么,就只會支持這三種格式的上傳。注意是用|分割。 , success: function (res) { // 成功后圖片預覽 $("#yl").html('<img src="' + res.url + '" width="100px" height="100px"/>'); } }); }); </script> </body> </html> ~~~ 訪問[http://www.phper.com/index/layer/upload](http://www.phper.com/index/layer/upload) ![](https://box.kancloud.cn/6157501bc6c90231fa089274341772ad_388x199.png) 從上面的配置可見,layer/doupload 通過這個接口,處理文件上傳的。而這個文件的名字 就是 input 框的 name 值。這個接口的返回值必須為: ~~~ {"code":0 ,"msg":"","url":"http://cdn.abc.com/123.jpg"'} ~~~ code = 0,表示成功。看一下 doupload 方法 ~~~ // 處理上傳文件 public function doUpload() { $img = request()->file('up_file'); // 移動到框架應用根目錄/public/uploads/ 目錄下 $info = $img->move(ROOT_PATH . 'public' . DS . 'layer_uploads'); if($info){ // 成功上傳后 獲取上傳信息 return json(['code' => 0, 'msg' => '', 'url' => '/layer_uploads/' . $info->getSaveName()]); }else{ // 上傳失敗獲取錯誤信息 return json(['code' => 1, 'msg' => $img->getError(), 'url' => '']); } } ~~~ 這樣上傳完文件,就可以預覽了。 ![](https://box.kancloud.cn/b453faaf7bb49c9f742924567acd21a4_789x606.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看