Support the ongoing development of Laravel.io →
posted 8 years ago
Input Forms
Last updated 2 years ago.
0
Solution

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;
}
Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

3svb 3svb Joined 16 Feb 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.