I am hosting my laravel on a Cpanel that not sups symlink so when I run storage:link
i get this error :
symlink() has been disabled for security reasons
when I contacted my provider they told me that they can’t open it but I have to make changes in my file system to read from the storage itself.
now my question is how can I change the config/filesystem.php
to not read from symlink but the storage folder itself. thanks in advance
2
Answers
You have a couple options.
If you have access to the command line, you can attempt to manually create the symlink yourself. It’s possible they disabled the PHP
symlink()
command, but the OSln
command may still be available to you. From the command line:If you don’t have access to the command line, you can attempt to run the command from PHP using one of the program execution methods (
exec()
,shell_exec()
, etc.). However, if they’ve disabledsymlink()
, they’ve probably disabled all of those, as well. To attempt this, create a temporary route, hit it once, then delete it:If you don’t have a way to run the
ln
command, or if it has been disabled at the OS level, then you’ll need to manually create yourpublic/storage
folder and update your filesystem config to point to it. Once you’ve created thepublic/storage
folder, open yourconfig/filesystems.php
file and update theroot
key for your public disk to point to it:I too had got this problem when I had used shared hosting. Actually storage:link implementation is not a tough, but you do not have permission to use that command.
Create a folder inside public folder. In my case I have created uploads, you can make any folder and sub folders.
In Controller, upload file with public_path(). For example purpose I am uploading image.
Use asset() to access files. For example purpose I am using img tag.