Voyager for Laravel 5: Wrong paths for images
Asked Answered
M

10

5

Having created a new user via Voyager, the avatar was showing as a broken image. I uploaded a new image, but the image remained broken.

I checked with Console in Google Chrome and found 3 404 errors:

2017-06-19 10:53:50.159 http://localhost:8888/storage/users/June2017/ypKlbqbATDbpnYctZBFp.png Failed to load resource: the server responded with a status of 404 (Not Found)

2017-06-19 10:53:50.256 http://localhost:8888/storage/users/June2017/ypKlbqbATDbpnYctZBFp.png Failed to load resource: the server responded with a status of 404 (Not Found)

2017-06-19 10:53:50.473 http://localhost:8888/vendor/tcg/voyager/assets/images/bg.jpg Failed to load resource: the server responded with a status of 404 (Not Found) When I looked at the project, the paths for the 2 storage errors are: http://localhost:8888/storage/app/public/users/ and: http://localhost:8888/storage/app/public/users/June2017

While in Media, I'm seeing similar path problems when navigating the folders:

2017-06-19 11:38:22.248 %7B%7B%20selected_file.path%20%7D%7D:1 GET http://localhost:8888/development/PhpstormProjects/Search4Venues/public/admin/%7B%7B%20selected_file.path%20%7D%7D 404 (Not Found)

Anticipating the question, in .env, I have: APP_URL=http://localhost:8888

Is this a configuration error?

EDIT

A colleague with more experience than me has been through Voyager and found some inconsistencies, which he's attempted to fix.

In app.php, we've had to change:

'url' => env('APP_URL', 'http://localhost:8888/development/PhpstormProjects/Search4Venues'),

... to:

'url' => env('APP_URL', 'http://localhost:8888'),

In filesystems.php, we've had to change:

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

... to:

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

However, he discovered other problems in config/voyager.php:

'assets_path' => '/vendor/tcg/voyager/assets',

... where it too appears to be missing PhpstormProjects/Search4Venues from the path:

http://localhost:8888/vendor/tcg/voyager/assets/images/bg.jpg

At this stage, we have no idea what else could be wrong with Voyager.

Mitigate answered 20/6, 2017 at 8:6 Comment(1)
I have similar issues, as per docs I know that localhost:8000 should be .env values.Colincolinson
S
6

Firs u need edit file .env:

APP_URL=http://localhost

to:

APP_URL=http://yout-site-url

After that u need edit the file fylesystem.php like this:

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

I was helped

Strachey answered 13/12, 2017 at 0:33 Comment(0)
E
3

Follow these steps:

1.Change APP_URL in the .env file to your website url.

For example:

APP_URL=http://localhost

to

APP_URL=http://127.0.0.1:8000

2.Create symbolic link by: (if not done yet)

php artisan storge:link

3.Restart your server (must. Otherwise chages will not be applied.)

Enjoy answered 25/8, 2018 at 5:28 Comment(0)
G
3

this is common problem that even official site of voyager is mention about just read this page https://voyager-docs.devdojo.com/troubleshooting/using-https

in summery just open file filesystem.php in the folder config and delete this line of code 'url' => env('APP_URL').'/storage',

Gudrun answered 4/1, 2019 at 7:58 Comment(1)
also, do note that you need to wrap Voyager::image('...') with asset eg. asset(Voyager::image('')). This is the correct answer.Jiggerypokery
R
1

Update you .env file

APP_URL=http://localhost:8000

and then run

php artisan config:clear

last

restart your serve

this work for me.

Rayraya answered 28/10, 2019 at 1:53 Comment(0)
V
0

This error sometimes usualy shown if we runing php artisan serve with default port like localhost:8000, but if you place laravel wit voyager in htdocs/www in your own server like xampp/mamp etc this error will gone,

So you can try :

  1. Installing apache or stand alone webserver like wamp or mamp
  2. place your project in htdoc/www folder, and don't forget to set .env app_url:localhost (or your domain without port)
  3. change document root in apache config to your project folder
  4. acces http://[your_domain]/[your_project]
  5. done..

thank's

Viddah answered 29/5, 2018 at 6:59 Comment(0)
S
0

Updated .env file:

APP_URL=http://localhost:8000

Fixed issue

dont forget to restart the server

Swarth answered 24/8, 2018 at 10:40 Comment(0)
D
0

Updated .env file:

APP_URL=http://localhost/voyager

And Updated filesystems.php

'public' => [
     'driver' => 'local',
     'root' => storage_path('app/public'),
     'url' => env('APP_URL').'/storage/app/public',
     'visibility' => 'public',
 ],
Dotterel answered 25/7, 2019 at 19:51 Comment(0)
V
0

All you need to do is change in .env

APP_URL = http://localhost

to

APP_URL = http://<whatever your site is called>

And then move to the pic files to

public users

For some reason voyager stores them in

public users\users

At least it did for me Just check what URL Voyager creates for the avatars and move them into the public folder with the same URL.

Worked for me at least

Voletta answered 27/10, 2019 at 14:43 Comment(0)
C
0

Change one line in .env file:

APP_URL = http://localhost

to

APP_URL = http://<your site url>

The command is used to remove the configuration cache file and created again.

php artisan config:cache
Condorcet answered 20/2, 2020 at 7:54 Comment(0)
S
0

if you using laragon, change

'url' => env('APP_URL').'/storage'

to

'url' => env('APP_URL').'./storage'
Smothers answered 14/5, 2020 at 21:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.