TP6上传文件报Disk [local] not found

浏览:1401 发布日期:2020/05/12 分类:ThinkPHP6专区
    $fileKey = key($_FILES);
   // ...业务代码
    $file = request()->file($fileKey); 
   $info = $file->rule('uniqid')->move(ROOT_PATH.'/upload/'.$dir."/".date('Y-m'));
    if($info){
        $filePath = $info->getPathname();
        $filePath = str_replace(ROOT_PATH,'',$filePath);
        $filePath = str_replace('\\','/',$filePath);
        $name = $info->getFilename();
        $imageSrc = trim($filePath,'/');
    }
这是TP5的上传方法,在TP6中应该怎么写?
$info我改成如下:
$info = \think\facade\Filesystem::putFile(request()->root().'/upload/'.$dir."/".date('Y-m'),$file,'uniqid');
然后会报错:
Disk [local] not found.


config目录下的filesystem配置如下:return [
    // 默认磁盘
    'default' => env('filesystem.driver', 'local'),
    // 磁盘列表
    'disks'   => [
        'upload' => [
            // 磁盘类型
            'type'       => 'local',
            // 磁盘路径
            'root'       => app()->getRootPath() . 'upload',
            // 磁盘路径对应的外部URL路径
            'url'        => '/upload',
            // 可见性
            'visibility' => 'public',
        ]
    ]
];
求大神指点
最佳答案
评论( 相关
后面还有条评论,点击查看>>