Answer the question
In order to leave comments, you need to log in
How to save photo on s3 in Larael?
there is such a code
$file = $request->file('image');
$avatar = Image::make($file);
$avatar->resize(280, 280, function ($constraint) {
$constraint->aspectRatio();
});
$filename = $file->getClientOriginalName();
$mime = $file->getClientOriginalExtension();
$filename = md5(time() . $filename) . '.' . $mime;
$new_path = env('STORAGE_SHOP_AVATAR');
$avatar->save(Storage::disk('s3')->path($new_path . $filename), $avatar->filesize() > 200000 ? 80 : null);
code: 500
error: true
message: "Can't write image data to path (webassets/shops/avatar/c9c9243b028d6ee91efd2a80a0568d6e.png)"
Answer the question
In order to leave comments, you need to log in
did so
$file = $request->file('image');
$avatar = Image::make($file);
$avatar->resize(280, 280, function ($constraint) {
$constraint->aspectRatio();
})->encode(null, $avatar->filesize() > 200000 ? 80 : null);
$filename = $file->getClientOriginalName();
$mime = $file->getClientOriginalExtension();
$filename = md5(time() . $filename) . '.' . $mime;
Storage::disk('s3')->put($path . $filename, $avatar);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question