Symbolic link does not work on Laravel

Asked

Viewed 2,283 times

1

I’m trying to make a folder inside the directory public Storage of Laravel, but I was unsuccessful. The folder to be made public is on the way:

project/storage/app/images

Yes, outside the public. I’ve tried to create the symblink usually with:

php artisan storage:link

And even created the link symbolic, but not yet obtained access to images.

Later I tried:

ls -l -s "project/storage/app/images" "project/public/"

Also unsuccessful.

  • You can redirect via .htaccess or configuration of Nginx. If you use any of them.

  • I didn’t understand how htacess would help me, since the images are only in /app/images/ but I would like to know how :) Thanks for the reply!

  • If I understand correctly, you want to access https://www.example/storage/app/images and have access to the files in the folder /project/storage/app/images. If so, in the Nginx and Apache you can use the alias

  • No, I can only display the images that are in admin/public in Laravel and, as is not the case, it is necessary to create something that allows such a thing...

  • Is your environment windows? Using something like a Vagrant machine?

  • Ubuntu, not my friend.

  • With Storage:link you create the symbol link and when to access it will be Storage/app/images/IMG.jpg. Tried so and still it didn’t work?? No error running command?!

  • How are you trying to access the public file? I mean, by which URI?

  • Anthonyrodrigues : no, all right, you even created the symbolic link icon. tropicoder12 : With the following URL: project.local/Storage/public/images/image.jpeg

Show 4 more comments

1 answer

1

When you create the link to your public website, access to it becomes via <host_do_projeto>/storage/<nome_do_arquivo>, that is, if you upload a file to your public archive as foo.txt, access to it will be through <seu_host>/storage/foo.txt, and the same thing for files in subfolders, for example <seu_host>/storage/bar/foo.txt. You can still use the function asset() to generate the file access link, for example echo asset('storage/foo.txt');

Try again, by the php artisan storage:link create access to the public directory, store your public access files in it with Laravel’s own functions and access the way I mentioned that is the correct way to use this form of storage.

In the documentation has all this in more detail and with other forms of storage.

  • But I already do so, for example: project.local/Storage/public/images/image.jpeg

  • And it still didn’t work? This file path "/public/images/image.jpeg" was you who defined it at the time of upload?

  • Put in question the code that uploads to see how the file is going up.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.