tp6多文件上传

2022-05-23 09:07:17 浏览数 (1)

代码语言:javascript复制
<?php
declare (strict_types = 1);

namespace appadmincontroller;
use thinkfacadeView;
class Index
{
    public function index()
    {
        return View::fetch('index');
    }
   /**
     * TP6多文件上传操作
     */
    public function uploadAct01()
    {
        // 获取表单上传文件 
        $files = request()->file('files');

        $savename = [];
        foreach($files as $file){
            $savename[] = thinkfacadeFilesystem::disk('public')->putFile( 'files', $file);//:disk('public')->putFile( 'files', $file);是路径:public/files/时间目录/图片
        }
        print_r($savename);
    }
}
代码语言:javascript复制
<form action="/index.php/admin/index/uploadAct01" enctype="multipart/form-data" method="post">
  <p>请选择文件1: <input type="file" name="files[]" /> </p>
  <p>请选择文件2: <input type="file" name="files[]" /> </p>
  

  <p><input type="submit" value="提交"></p>
</form>

0 人点赞