这是我的功能,它在我的计算机上运行,但当我在DigitalOcean Ubuntu服务器上运行它时,它会给我file_get_contents(): Filename cannot be empty
错误
public function uploadFile($request)
{
$imageName = time() . '.' . $request->file('profile_photo')->getClientOriginalExtension();
$image = $request->file('profile_photo');
Storage::disk('s3')->put($imageName, file_get_contents($request->file('profile_photo')), 'public');
return $imageName;
}
考虑使用此结构来存储照片:
public function uploadFile($request)
{
$imageName = time() . '.' . $request->file('profile_photo')->getClientOriginalExtension();
$path = $request->profile_photo->storeAs('public', $imageName, 's3');
return $imageName;
}
文档:https://laravel.com/docs/8.x/requests#storing-上传文件