Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media not show image after upload if location out side public folder #5362

Closed
aroon9002ahmed opened this issue Jun 10, 2021 · 10 comments
Closed

Comments

@aroon9002ahmed
Copy link

Version information

  • Laravel: v8.46.0
  • Voyager: v1.4
  • PHP: 7.4
  • Database:MySQL

Description

Media not show image after upload if location out side public folder

APP_URL=http://localhost:8000

filesystem:


    'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
        ],

        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],

        's3' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => env('AWS_URL'),
            'endpoint' => env('AWS_ENDPOINT'),
            'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
        ],

    ],

Screenshots

if upload outside public folder
https://s1.im.ge/2021/06/10/N1p8.jpg

if upload inside public folder
https://s1.im.ge/2021/06/10/NOCX.jpg

@emptynick
Copy link
Collaborator

Not sure I understand you.
The public folder is the only folder that is accessible from your browser.

@aroon9002ahmed
Copy link
Author

there 2 folders inside media
check this screenshot
https://s1.im.ge/2021/06/11/NyDL.jpg

@volkankocaali
Copy link

I had the same problem.
I solved the problem by making the FILESYSTEM_DRIVER value in the env file public.

And don't forget to php artisan optimize

@diegodeluca
Copy link

I found an unorthodox solution, maybe can help.
In \config\filesystems.php i changed from
public_path('storage') => storage_path('app/public'),
to
public_path('storage') => storage_path('app'),
deleted (if present) the storage symlink in public folder
regenerate the symlink in public folder with php artisan storage:link

Obviously it will affect the whole application, so you must check all the places where you used the symlink

@pro-cms
Copy link

pro-cms commented Jun 11, 2021

Hellow, simply go to filesystem , look at the local drive , update root path to app/public
i.e change from

'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],

to
'local' => [
'driver' => 'local',
'root' => storage_path('app/public'),
],

your problem should be fixed

@aroon9002ahmed
Copy link
Author

Thank you @pro-cms

@MrCrayon
Copy link
Collaborator

@aroon9002ahmed @pro-cms
It would be better to leave filesystem config untouched and change voyager config file to use public storage.

An explanation on what's happening:
Voyager config file defines which storage to use like this:

'storage' => [
    'disk' => env('FILESYSTEM_DRIVER', 'public'),
],

Since FILESYSTEM_DRIVER was not defined by default in Laravel the public storage was used, but in Laravel 8.5.19 the default value was added.

laravel/laravel@c5d38d4#diff-a3046da0d15a27e89f2afe639b25748a7ad4d9290af3e7b1b6c1a5533c8f0a8c

@emptynick @fletch3555 should we change voyager config file and just set public or any other idea?

@MrCrayon MrCrayon reopened this Jun 12, 2021
@emptynick
Copy link
Collaborator

Yeah I think we can do that

MrCrayon added a commit to MrCrayon/voyager that referenced this issue Jun 12, 2021
laravel/laravel 8.5.19 introduced a default value for FILESYSTEM_DRIVER

Fixes thedevdojo#5362
@MrCrayon MrCrayon mentioned this issue Jun 12, 2021
@pro-cms
Copy link

pro-cms commented Jun 12, 2021

@aroon9002ahmed @MrCrayon @emptynick #5364 is the best solution , thank you

@github-actions
Copy link
Contributor

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants