Fixed! The problem was that on the online server, the application folder is placed OUTSIDE the public_html folder. Therefore the public_path() was pointing at the "wrong" folder.
# root
## laravel
## public_html
### images
#### users
Therefore the application was uploading the images into
# root
## laravel
### public
#### images
I managed to resolve this with a quick fix in the controller.
if ($request->file('profile_pic')->isValid()) {
$path = base_path();
$path = str_replace("laravel", "public_html", $path); // <= This one !
$destinationPath = $path . '/images/users'; // upload path
$extension = $request->file('profile_pic')->getClientOriginalExtension(); // getting image extension
$fileName = uniqid() . '.' . $extension; // renameing image
$request->file('profile_pic')->move($destinationPath, $fileName); // uploading file to given path
$user->profilepic = $fileName;
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community