Voyager: Wrong uploaded files path on shared hosting

Created on 21 Dec 2016  路  11Comments  路  Source: the-control-group/voyager

  • Laravel Version: 5.3
  • Voyager Version: 10.4.0
  • PHP Version:
  • Database Driver & Version: MySQL

Description:

Files are being uploaded to /laravel/storage/app/public/ and the saved path on the database is http://www.mywebsite.com/storage... I need to fix this.

I have a subfolder in my website. To enter the system one should go to:

www.mywebsite.com/system/admin.

If I upload a file, the generated url is:

 http://www.mywebsite.com/storage/services/December2016/KJTl0xfFa7Rnec5QLuii.jpg

where services is a table I've created via admin panel... but the file is not being uploaded to this location. When I access it I've got a 404 error. For the older files, which I've uploaded locally, if I type:

http://www.mywebsite.com/system/storage/

I can find them, under each model folder... but the new files are not being uploaded to there. They're being uploaded under

/laravel/storage/app/public/

If I change the path and try to use /../../public_html/system/ on the config/voyager.php file, I've got an error Path is outside of the defined root

My laravel folder is on the same level as the public_html folder, which is where my system/index.php file is located.

How can I fix the route to change the location to where the uploaded files are actually stored? Ideally, I'd like to store them under system/storage folder or at least to get the routes to find the files using the correct path and saving the correct path on my database.

question

Most helpful comment

Don't upload the symlink, remake the symlink on the server instead.

All 11 comments

The config value of voyager.storage.subfolder should be left at public/.
However what you need to do here is to remove the symbolic link public/storage and instead make a new symbolic link from public/system to storage/app/public.

I've made this but once I've uploaded the files to my server the links were pointing to my system location, users/jaqueline/bla/bla/bla/ Is there any other way to make it? I've tested both, the laravel command php artisan storage:link and ln -s storage/app/public/ public/storage. They work locally but not on my host, since the path is not the same. I'm using a mac and I've got this limitation that doesn't allow to create a relative symbolic link... Is there any other approach to fix this issue?

Don't upload the symlink, remake the symlink on the server instead.

@Jaquedeveloper, as @marktopper said, symlinks have to be created on the machine they need to live on, i.e. the remote server. Please confirm that this resolved your problem and close the issue (or let us know and we can close it for you)

for VPS that is easier but in case someone using Share Hosting, that is quite hard to touch terminal for rebuilding a new symlink. @fletch3555 @marktopper

@uchsarath,

It's true that functionality is often limited on shared hosting, though that's the price you pay when you want cheap hosting. Most shared hosting providers come with cPanel (or similar), which should include the ability to create a symlink through the GUI. Uploading the symlink simply will not work as expected.

I'm closing this issue for now as there have been multiple responses by maintainers, and no response from the reporter in 3 weeks. If this is still an issue on the current version, please let me know and we'll reopen it.

What will happened if voyager stops using the symlink and use the public folder directly ? The symlink is a pain in the ass.

You wont be able to define another disk anymore.
By the way, this issue is 1.5 years old and closed

My symlink has been successfully created but voyager still cannot access the images in it.

As @emptynick said, this issue has been closed for well over a year

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ferrywae picture ferrywae  路  4Comments

MikadoInfo picture MikadoInfo  路  3Comments

abacram picture abacram  路  3Comments

craigb88 picture craigb88  路  3Comments

raoasifraza1 picture raoasifraza1  路  3Comments