$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',
]
]
];求大神指点 最佳答案