第一种:修改config里边的filesystems.php文件,在disks中加入下列代码
'local' => [ 'driver' => 'local', 'root' => storage_path('../public/'), ], 'public' => [ 'driver' => 'local', 'root' => storage_path('../public/'), 'url' => env('APP_URL').'/storage', 'visibility' => 'public', ],
接受文件:
$data['image']=Request::file('image')->store("month");
file中是上传的文件名称,store中是文件要存放的文件夹。
第二种:在disks中加入下列代码
'uploads' => [ 'driver' => 'local', 'root' => public_path('uploads'), ],
接受上传文件:
$file=$request->file('photo'); $extentsion=$file->extension(); $name=md5(date('YmdHis')).'.'.$extentsion; $result=move_uploaded_file($file->getRealPath(), public_path().'/uploads/'.$name); // // dd($result);