php - laravel upload Can't write image data to path

I'm trying to storebase64Image
with laravel but it returns this error:
Can't write image data to path (/home/u187504358/domains/example.com/public/images/Group-1590235658.jpg)
Code
if ($request->photo) {
$photo = $request->photo;
$filename = 'Group' . '-' . time() . '.' . 'jpg';
$location = public_path('images/'. $filename);
Image::make(file_get_contents($photo))->resize(500, 500)->save($location);
$oldFilename = $group->photo;
if(!empty($group->photo)){
Storage::delete($oldFilename);
}
$group->photo = $filename;
}
filesystem.php
'default' => env('FILESYSTEM_DRIVER', 'local'),
'disks' => [
'local' => [
'driver' => 'local',
'root' => public_path('images/'),
],
]
Any idea?
Answer
Solution:
Solved
I've added this code to myindex.php
file inpublic aka public_html
folder and it works now
$app->bind('path.public', function() {
return __DIR__;
});
Note: As you see in error it tries to connect with folder
public (domains/example.com/public/images)
but in server (shared host) there ispublic_html
folder. So it made me think twice that laravel tries to connect to the wrong path and code above solved the issue.
-Hope it help others.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: please make sure the php redis extension is installed and enabled.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.