Upload.php 1001 字节
<?php

namespace Controller;


/**
 * 上传文件
 * @author:dc
 * @time 2023/4/18 10:31
 * Class Upload
 * @package Controller
 */
class Upload extends Base {


    /**
     * 上传图片
     * @return array
     * @throws \Lib\Err
     * @author:dc
     * @time 2023/4/18 10:32
     */
    public function image(){

        $files  =   app()->file('files');

        $result = [];

        if($files){
            foreach ($files as $file){
                $file->verify([
                    'ext'   =>  ['jpg','png','gif','jpeg'],
                    'size'  =>  1024*2,
                    'mine'  =>  ['images/jpeg','images/gif','images/png']
                ]);

                if($file->move()){
                    $result[]   =   [
                        'name'  =>  $file->name,
                        'saveUrl'  =>   APP_HOST.$file->savePath.$file->saveName
                    ];
                }

            }
        }

        return $result;

    }







}