Files in public folder using Laravel 4.2 are inaccessible

Asked

Viewed 306 times

1

Hello,

I have an application where some files are created in the folder public of Laravel 4.2, then send an email to the user with the URL’s to download these files, but there is an error when trying to download.

inserir a descrição da imagem aqui

Initially it seems to involve the routes of Laravel, the question is, is it necessary to create routes for each download that I will make available? How can I be doing this? And if not necessary, what configuration should I make so that the files in the public folder can be accessed by other users?

Thank you for your attention.

1 answer

2


There is no need to define the routes for each download. You can access the static files using Laravel 4 normally.

You should first keep in mind that the root of an Laravel 4 application is not in the folder where your application files are found, but rather the folder public.

Apache Note (or any other server you use) Should be made to the folder public.

So if you have a static file in the path public/imagens/0001.png, you won’t be able to access it with meusite.com.br/public/imagens/0001.png, for the folder public is the root folder of the application.

The correct path in the above example would be: meusite.com.br/imagens/0001.png.

Remember: If your Laravel 4 application is inside a folder called meusite the Apache note should be made to meusite/public.

A good way to test if your application has been configured correctly is to put this code in `Routes.php'

dd($_SERVER['DOCUMENT_ROOT']);

If I show the way with public in the end, it means that it is with the correct configuration (or say, the Laravel standard).

  • 1

    It really went unnoticed the question of the public folder, I thank the help, the problem was solved.

  • If you need anything about Laravel, you can count on us :p

Browser other questions tagged

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