1,filesystem.php配置文件不需要改动,如图
tp6文件上传去除默认时间子目录

return [
// 默认磁盘
'default' => env('filesystem.driver', 'local'),
// 磁盘列表
'disks'   => [
    'local'  => [
        'type' => 'local',
        'root' => app()->getRuntimePath() . 'storage/',
    ],
    'public' => [
        // 磁盘类型
        'type'       => 'local',
        // 磁盘路径
        'root'       => app()->getRootPath() . 'public/storage/',
//            'root'       =>  '/data/www/assets/somi/',
        // 磁盘路径对应的外部URL路径
        'url'        => '/storage/',
        // 可见性
        'visibility' => 'public',
    ],
    // 更多的磁盘配置信息
 ],
];

2,默认有时间子目录代码如下

$savename = Filesystem::disk('public')->putFile($path, $files);

上传文件地址如下:
tp6文件上传去除默认时间子目录

3,在putfile后面添加uniqid,自定义

$savename = Filesystem::disk('public')->putFile($path, $files,'uniqid');

上传文件地址如图:
tp6文件上传去除默认时间子目录

时间子目录已去除

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-04
  • 2022-12-23
  • 2022-03-06
  • 2021-06-13
  • 2021-06-26
猜你喜欢
  • 2022-12-23
  • 2021-11-19
  • 2022-12-23
  • 2021-08-11
  • 2022-12-23
  • 2021-08-24
  • 2022-12-23
相关资源
相似解决方案