A
A
Anatoly2019-04-05 13:55:49
Laravel
Anatoly, 2019-04-05 13:55:49

How to properly resize an image and save it in storage?

Greetings!
Tell me how to resize an image on upload and save it in Storage using the putFile() method?

$img = Image::make($this->file['tmp_name']);
$img->resize(1000, 1000, function ($constraint) {
  $constraint->aspectRatio();
  $constraint->upsize();
});

Storage::putFile(config('path_to_image'), $img->stream());

The error is like this:
Call to undefined method GuzzleHttp\Psr7\Response::hashName()

I do this, but an error, and as soon as I didn’t try it)
I just want the name of the file to be automatically given.
With the put() method, everything works fine, but I don’t want to generate the name separately)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Crash XD, 2019-04-05
@crashxd

I use the library , it has convenient functions for resizing and so on.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question