Files in the public folder using Laravel 4.2 are inaccessible



I have an application where some files are created in the public folder of Laravel 4.2 , then send an email to the user with the URL's to download these files , but an error occurred while attempting to download.

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

Thank you for your attention.

asked by anonymous 13.12.2016 / 16:18

1 answer


It is not necessary to define routes for each download. You can access static files using Laravel 4 normally.

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

Apache pointing (or any other server you use) should be done for the public folder.

So, if you have a static file in the public/imagens/0001.png path, you will not be able to access it with , because the public folder is the root folder of the application.

The correct path in the above example would be: .

Remember: If your Laravel 4 application is inside a folder called meusite Apache appointing should be done for meusite/public .

A good way to test if your application has been properly configured is to put this code in 'routes.php'


If you display the path with public at the end, it means you have the correct configuration (or, say, the Laravel pattern).

13.12.2016 / 16:32