Voyager: Uploaded images not working

Created on 14 Dec 2017  路  35Comments  路  Source: the-control-group/voyager

  • Laravel Version: 5.5
  • Voyager Version: latest
  • PHP Version: 7.1

Description:

When i upload a new image or file, its not showing on browser, but the image is correctly on my filesystem. Primary images from install are correctly display

Already tried

  • Change my APP_URL in .env
  • Try if existis on /storage/app/public/posts

Steps To Reproduce:

voyager-img01

voyager-img02

voyager-img03

voyager-img04

voyager-img05

Most helpful comment

It's simple. I had exact same problem. So here's my fix...
Simply delete the storage folder shortcut in the public folder.
The re-run the symlink command "php artisan storage:link" from your terminal
That's it.
Lemme know if it worked for you

All 35 comments

Hi @leocarmo, I noticed that the standard Voyager files are in .JPG, and what you're trying to upload is .PNG. Have you tried uploading a .JPG file to see if the problem still continues?

Hi @mateushackfaccat , tks for your attention.

Same problem... Its not only with images, files too

voyager-img06

voyager-img07

Have you checked whether the folders where Voyager is running have all the permissions?
From what I can see, it creates the file call in the database, but does not actually save the file.

I'm glad that more Brazilians are using Voyager. :)

Yes, all permissions are the same... And all exists

Yeah! Im tryng :)

voyager-img08

I do not know what might be happening then. Have you tried installing a new instance of Voyager to run a test and see if that installation is not in trouble?
Another possibility could give the composer update command to update Composer and other dependencies.

Yes, already done... I tryed 3 times another instance. When i used laravel 5.4 everything run, but on 5.5 i have this problem

I do not know what might be happening then. :(

Please reload the page with your browser's devtools open and record the requests for those images (one working, one "broken"). For each, please share with us what the URL is for the image, as well as the mime-type being sent by the server, and any other information you believe may be relevant ("size", etc).
If you'd like to repeat the process with files that do/don't work, that would be appreciated as well.

Additionally, please share a screenshot of your public folder indicating that the public/storage symlink is set up properly.

Anyway thanks for the help @mateushackfaccat

Thanks for the answer @fletch3555

Yes, something is wrong with the type:
voyager-img09

public\storage
voyager-img10

@leocarmo, Can you please look at the network request for POST /media/files? I'm interested in the response. It should contain JSON-formatted metadata about each file in that folder. For each file, there should be a type field containing the mimetype (ref).

@fletch3555 take a look:

voyager-img11

i have same issue, Any solution master ?

hi, i was facing such problem, i've managed to fix the issue by updating APP_URL in .env file from http://localhost to my website domain name http://example.org

no solution sir ?

nothing... @x5c

I had a same problem. I update my .env for new domain but due to production and cache it stay same until I ran php artisan config:cache to force Laravel to get&cache new value from .env file.
Read more: hear

php artisan storage:link

hi, i had the same issue.
In my case i found the problem....
All files from voyager was working, but my uploads not......
i checked my public_html folder from hosting, and i found in there a FOLDER called storage, and guess what, the app was reading from this folder(/public_html/storage) and not from my /projectname/storage/app/public, i renamed the storage folder, and use this to create the link to proper folder:
<?php $target = '/home/{your user name on hosting website}/{your project name}/storage/app/public'; $shortcut = 'storage'; symlink($target, $shortcut); ?>
by default voyager try to create symlink, but on my hosting he just copied the folder :)

@chirill, since you mentioned public_html, I'm guessing you're on shared hosting, with a non-default setup (public_html is your public folder). Did you also override path.public in AppServiceProvider so laravel knows how to find the public directory? This is how laravel knows where to put the symlink, and therefore where voyager puts it. Not doing so is likely the root cause for your issue

@fletch3555, i didn't override path.public.
i edited my index.php at require __DIR__. and $app to get back and to go to my project folder

Both would be needed. What you did is enough to get laravel to work, but what I suggested is needed for anything calling the public_path() method, which is common for packages publishing static assets (css/js/images), as well as the artisan storage:link command

I set this
public function register() { $this->app->bind('path.public', function() { return base_path().DIRECTORY_SEPARATOR.'public_html'; }); }
in AppServiceProvider, now at dashboard voyager offer me to fix symlink, i click fix and get an error
symlink(): No such file or directory

In Unix systems, check your storage file owners.
It must be same user with php and nginx/apache etc.

It's simple. I had exact same problem. So here's my fix...
Simply delete the storage folder shortcut in the public folder.
The re-run the symlink command "php artisan storage:link" from your terminal
That's it.
Lemme know if it worked for you

I currently have this problem in production

Symlink is created
App_url is updated

Still the images are broken (avatars, etc)
However the previous images work on the frontend, I'm unable to upload new ones as it gives an error

encountered the same issue,

currently my voyager app's core is not saved in httdocs,

what i notice is that when I copy images to httdocs/myapps/storage it correctly displays. But when I upload it goes to the public/storage

php artisan storage:link

yep, i ran php artisan storage:link couple of times, it doest not fix the issue.

having the same issue. I changed the admin background image through the options but after the image is uploaded it does not show. Dev tools show 404. Media does not load the image as well.
I can't create a symlink because I'm on corporate network and I do not have admin privileges to create it.

Everything else is working properly. Important to say that I had to move the project to a subfolder. Locally the image is loaded after an upload. Using the server the image does not show.

I have uploaded an image to use in a dimmer and it works just fine. It did not work while using admin image background upload.

I found my issue.
My .env APP_URL was set as localhost =P
Now it works just fine!

I had same exact issues. changing my APP_URL .env did solve my problem although that is the most suggested solution here, I wasn't able to fix it until I found this video, https://www.youtube.com/watch?v=8FjqHsmAeCM . I hope this will also fix yours.

I'm going to close this since it's so old and multiple causes/solutions have been identified, all related to misconfiguration.

I have solved this issue by adding the below code in filesystems.php and mentioned in .env as

FILESYSTEM_DRIVER=production

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

I solved the issue by adding this to AppServiceProvider.php in register function

$this->app->bind('path.public', function() {
//use this if you are using a subdomain
return dirname(getcwd().DIRECTORY_SEPARATOR.preg_replace('#^https?://#', '',env('APP_URL')));
// use this if you are using public_html
// return dirname(getcwd().DIRECTORY_SEPARATOR.'public_html');
});
and then php artisan storage:link

This works for Shared hosting only

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vaggelis2018 picture vaggelis2018  路  3Comments

rayqiri picture rayqiri  路  3Comments

ferrywae picture ferrywae  路  4Comments

MikadoInfo picture MikadoInfo  路  3Comments

raoasifraza1 picture raoasifraza1  路  3Comments