我已经成功创建了一个托管在 Heroku 上的 Laravel 5.4 网络应用程序。我还设法将图像上传到 AWS S3。然而,图像被上传为空白或空的。我尝试了各种在线资源,但未能找到解决问题的方法。下面我附上了我的 Controller ,我认为这是导致错误的原因。
public function updateavatar(Request $request, User $user){
if($request->hasFile('avatar')){
$avatar = $request->file('avatar');
$filename = time() . '.' . $avatar->getClientOriginalExtension();
// $destinationPath = public_path('/uploads/avatars/');
$imageS3 = Image::make($avatar)->resize(300,300);
Storage::disk("s3")->put($filename, $imageS3->__toString());
//$disk->put("img/album/$id/$filename", $image->__toString());
$motcall = $this->carCheck($user);
$user = Auth::user();
$user->avatar = $filename;
$user->save();
}
最佳答案
我已经通过将存储行更改为 Storage::disk("s3")->put($file name, file_get_contents($avatar)); 设法解决了这个问题。
P.S 它忽略了图像裁剪
关于php - Laravel 5.4 Image Intervention 上传图片到 S3 0 Bytes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50066110/