Search code examples
laravellaravel-5laravel-storage

Symlink(): no such file or directory because public folder is in a different directory


I'm working on an application and wanted to implement image uploading to my application. Now when I want to create the symbolic link for my files, I get the following error:

ErrorException : symlink(): No such file or directory

Exception trace:
symlink("/home/user/private/application/storage/app/public", "/home/user/private/application/public/storage")

I know what the cause of this is, but i don't know how to fix and/or have a workaround for it.

I have my public folder in my html_root directory, and have the rest of the application in a directory outside of my html_root. In this case /home/user/private/application.

when I use php artisan storage:link it tries to find the public folder in my 'private' directory, but can't find it because my public folder is in html_root.


Solution

  • Problem solved by placing my html_root content back to my private folder in /home/user/private/application and creating a symlink of my public folder that goes to my /home/user and renaming the /home/user/public folder to /home/user/html_root (and keeping the symlink intact).

    So i remain with the official Laravel directory structure and make a faux (symlink) of the public folder.

    With this i can use the php artisan storage:link normally without creating a custom Command.