thinkphp6 上传文件
2022-11-24 11:10:29
152
{{single.collect_count}}

第一步:
config/filesystem.php 文件

return [// 默认磁盘'default' => env('filesystem.driver', 'public'),// 这里上传的文件会上传到 public/uploads/ 下// 磁盘列表'disks' => ['local'=> ['type' => 'local','root' => app()->getRuntimePath() . 'storage',],'public' => ['type' => 'local','root' => app()->getRootPath() . 'public/uploads','url' => '/uploads','visibility' => 'public',],'images' => ['type' => 'local','root' => app()->getRootPath() . 'public/uploads/images','url' => '/uploads/images','visibility' => 'public',],// 更多的磁盘配置信息],];

第二步:

public function fileUp(){$files = request()->file('image');if (empty($files)) {return to_json(0, '请选择上传文件', 1);}$savename = [];if (is_array($files)) {foreach($files as $file){$savename[] = \think\facade\Filesystem::putFile('topic', $file);}} else {$savename[] = \think\facade\Filesystem::putFile('topic', $files);}var_dump($savename);exit();}
回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}