Upload and structure for storing images in Laravel

2

I started to build a portal, using Laravel, which has the following requirements: users, places belonging to users and classifieds belonging to users .

As each of these requirements requires images, I would like to know the best method for storing images for each of these requirements and associated with them.

My question is more based on the structure of folders to store the photos, and about the system of uploading the images in Laravel.

    
asked by anonymous 15.01.2014 / 12:23

2 answers

3

There are several things to look for:

  • Is your deploy done by some automated tool? P. Capistrano? If so, the framework should be mounted outside the folder of your application (which is usually done in the public directory). You can also point the public directory to an external folder (via a symbolic link)
  • Will it write to any CDN / Cloud files? P. Amazon S3? In this case the structure is made by buckets, so you have to think a bit differently.

The structure could be something like:

shared/usuarios/
shared/usuarios/places
shared/usuarios/classificados

In case of option 1 would be folders, in option 2, buckets.

On the upload system there is no secret, the upload API is simple to use. I recommend that you save the path of these directories in configuration files, so you can easily move in the future if you need to.

Follow the docs link: link

    
15.01.2014 / 12:51
2

I use the codesleeve / stapler package

With it you will associate images with a record of the table you want to place an image.

In general I create a table only for the images and link the record of this table to a record of other tables, so I can have more than one image linked to the registry without difficulties.

One of the differences of this package is the possibility of sending your image to an amazon S3 bucket, which becomes a very good thing if you have to deal with many images.

    
15.01.2014 / 12:52