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

Uploaded images not working #2365

Closed
leocarmo opened this issue Dec 14, 2017 · 35 comments
Closed

Uploaded images not working #2365

leocarmo opened this issue Dec 14, 2017 · 35 comments

Comments

@leocarmo
Copy link

  • 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

@mateushackfaccat
Copy link

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?

@leocarmo
Copy link
Author

Hi @mateushackfaccat , tks for your attention.

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

voyager-img06

voyager-img07

@mateushackfaccat
Copy link

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. :)

@leocarmo
Copy link
Author

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

Yeah! Im tryng :)

voyager-img08

@mateushackfaccat
Copy link

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.

@leocarmo
Copy link
Author

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

@mateushackfaccat
Copy link

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

@fletch3555
Copy link
Collaborator

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.

@leocarmo
Copy link
Author

Anyway thanks for the help @mateushackfaccat

Thanks for the answer @fletch3555

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

public\storage
voyager-img10

@fletch3555
Copy link
Collaborator

@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).

@leocarmo
Copy link
Author

@fletch3555 take a look:

voyager-img11

@merby04
Copy link

merby04 commented Dec 20, 2017

i have same issue, Any solution master ?

@ostryanyn
Copy link

ostryanyn commented Dec 21, 2017

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

@merby04
Copy link

merby04 commented Jan 2, 2018

no solution sir ?

@leocarmo
Copy link
Author

leocarmo commented Jan 2, 2018

nothing... @x5c

@vafagh
Copy link

vafagh commented Feb 7, 2018

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

@gstoa
Copy link

gstoa commented Feb 10, 2018

php artisan storage:link

@chirill
Copy link

chirill commented Jul 3, 2018

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 :)

@fletch3555
Copy link
Collaborator

@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

@chirill
Copy link

chirill commented Jul 3, 2018

@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

@fletch3555
Copy link
Collaborator

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

@chirill
Copy link

chirill commented Jul 3, 2018

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

@yilmazerhakan
Copy link

yilmazerhakan commented Sep 26, 2018

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

@stantoju
Copy link

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

@BMCTeixeira
Copy link

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

@ledikari
Copy link

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

@cardinalwebma
Copy link

php artisan storage:link

@ledikari
Copy link

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

@Fenweldryn
Copy link
Contributor

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.

@Fenweldryn
Copy link
Contributor

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.

@Fenweldryn
Copy link
Contributor

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

@cessto103
Copy link

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.

@fletch3555
Copy link
Collaborator

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

@HariKumarValluru
Copy link

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',
        ],

@mf0wzi
Copy link

mf0wzi commented Sep 27, 2019

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

@thedevdojo thedevdojo locked as resolved and limited conversation to collaborators Sep 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests