boyjarv's avatar

uploading images, not showing

ok so now I have deloyed, I upload an image via NOVA and when I view it, I can see it goes into:

/public/storage/X7k7f1fNTpTVMwlfMJMX0tQaSQJEdSdHNp5Ujvrt.jpg

but it's not showing in my application or in Nova?!

0 likes
26 replies
boyjarv's avatar

The [/var/www/vhosts/mywebsite.com/httpdocs/moapi/public/storage] link already exists.

Snapey's avatar

look in your browser network tools

what url is it trying to load the image from?

siangboon's avatar

inspect the url of the image and open it in new tab... double check any mistake of the path or https/http issue....

anilkumarthakur60's avatar

@boyjarv check your public directory for the folder/file list public/storage/folder_list ....if not then delete storage folder from public directory and re link the storage folder

and in your .env file make some changes FILESYSTEM_DRIVER=public

boyjarv's avatar

theres this: Home directory > httpdocs > moapi > public > storage

and there is this: Home directory > httpdocs > moapi > storage > app > public

I'm so confused

Snapey's avatar

If you have run php artisan storage:link then storage/app/public and public/storage are one and the same (actually public/storage points to the storage folder)

If your browser cannot load an image then you need to look in the browser network tools and see what URI it is trying to load. Then compare that with where you think the file is.

Remember you can just enter the image URL directly in your browser to confirm

boyjarv's avatar

when I go there directly, it gives me a 403

Snapey's avatar

You left out a vital piece of information:

Forbidden You do not have permission to access this document.

You need to check the ownership of the files and make sure your webserver has permission

You have other permission problems not just images. EG if I try to access an invalid route:

The stream or file "/var/www/vhosts/jbiddulph.com/httpdocs/moapi/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

So you cannot write to log files either

Snapey's avatar

the image URL should not contain 'app/public'

https://www.mywebsite.com/storage/app/public/RZOB0PgcmeQGT1CvgGCwyahC6TASmIdGAK9D3p4V.jpg

should be

https://www.mywebsite.com/storage/RZOB0PgcmeQGT1CvgGCwyahC6TASmIdGAK9D3p4V.jpg
boyjarv's avatar

Thank you, that is also displaying:

Server Error 403 Forbidden

Snapey's avatar

because you have done nothing to investigate the permissions error

boyjarv's avatar

I just deleted the storage folder and ran:

php artisan storage:link --relative

still the same:

403

Snapey's avatar
Snapey
Best Answer
Level 122

What user are you logged in as when you create these files and folders?

What user account is the web server using?

Are your account and the webserver part of the same group?

You can answer these questions by listing the files and checking ownership

boyjarv's avatar

me:

/var/www/vhosts/mywebsite.com/httpdocs/moapi/public/storage

ls -l

-rw-r--r-- 1 jarv psacln 440963 Aug 5 19:48 RZOB0PgcmeQGT1CvgGCwyahC6TASmIdGAK9D3p4V.jpg -rw-r--r-- 1 jarv psacln 180990 Aug 5 19:46 x1VJSh4GNC2YvtME9LvawVMZGUdi8HlyuqGdOs10.jpg

Snapey's avatar

so the files are owned by jarv and the webserver (application) and cannot access them

boyjarv's avatar

ok..... so I did have a look at jarvs permissions but how can change the ownership to the webserver?

Snapey's avatar

You have to complete the steps I gave earlier. Then you can use chown to change ownership once you have uploaded the files.

1 like
boyjarv's avatar

so I just ran:

chown -R jarv:psacln storage

and now I get:

-rwxrwxr-x 1 jarv psacln 1794444 Aug  5 20:22 beqM06dNuPaiP73ymYuLskyPIRw5kfTzUuVrwp6N.jpg
-rwxrwxr-x 1 jarv psacln  440963 Aug  5 20:21 dlKew5f5ErVzwHdgoPrzdbG2khcsoTopdnlMXekH.jpg
-rwxrwxr-x 1 jarv psacln  440963 Aug  5 19:48 RZOB0PgcmeQGT1CvgGCwyahC6TASmIdGAK9D3p4V.jpg
-rwxrwxr-x 1 jarv psacln  180990 Aug  5 19:46 x1VJSh4GNC2YvtME9LvawVMZGUdi8HlyuqGdOs10.jpg
boyjarv's avatar

Thank you so much SNAPEY for all your help!

Please or to participate in this conversation.