I'm trying to use Intervention to resize an image, then save it in a disk that I've defined, but I can't get it to work. Using public_folder
is saving it in a folder in the root of my app called /public
I've created a new disk:
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'visibility' => 'public',
],
'images' => [
'driver' => 'local',
'root' => storage_path('app/public/images'),
'visibility' => 'public',
],
],
And I need to accept input from the user, then save their uploaded file to that disk, then the filepath to the database.
$fieldFile = $request->file($fieldName);
$imageName = time();
Image::make($fieldFile)->crop(350, 350)->save(public_path() . '/' . $imageName . '.' . $fieldFile->getClientOriginalExtension());
$object->$fieldName = public_path() . '/' . $imageName . '.' . $fieldFile->getClientOriginalExtension();
I'd like to end up with something similar to what should happen from
$fieldValue = $fieldFile->store($fieldName, 'images');
The file should end up at
/path/to/laravel/storage/app/public/images/
Later, if I change the images disk to s3 or somewhere else, I'd like this code to continue to function.