Thomas Shelby
Thomas Shelby

Reputation: 1370

Can I use storage directory to storage files

I have quick question. Is good idea to keeps files uploaded by user in app/storage directory in laravel? I think about users avatar and other images.

What exactly I should keep in storage directory? May I save files under this path?

Upvotes: 0

Views: 1565

Answers (2)

ollieread
ollieread

Reputation: 6301

You can store files wherever you want, that is entirely up to you. If you wish for them to be web accessible at all times, then put them into /public/.

If for example the files need to be restricted and only available via certain pages, say for example, for members of the site, without allowing hotlinking, you could store them in /app/storage/ and then load them through using headers and file_get_contents().

The structure is entirely yours to play with, do as you wish.

Upvotes: 1

Tali Luvhengo
Tali Luvhengo

Reputation: 359

As per http://laravelbook.com/laravel-architecture/

I put my images in the public directory.

/public/

The only folder seen to the world as-is. This is the directory that you have to point your web server to. It contains the bootstrap file index.php which jump-starts the Laravel framework core. The public directory can also be used to hold any publicly accessible static assets such as CSS, Javascript files, images and other files.

/app/storage/

The storage directory is used as temporary file store for various Laravel services such as sessions, cache, compiled view templates. This directory must be writable by the web server. This directory is maintained by Laravel and you need not tinker with it.

Upvotes: 2

Related Questions