-3

I'm going to try image file upload. Then, I thought there were two choices. First, I can save the image file into the directory which is not available for viewers. Second idea is that I can save the image binary data into the database.

Which is better? Or, could you tell me the advantages and disadvantages of these methods?

Finally, I'm going to use CakePHP.

Ken
  • 1
  • 3
    Unless there's a compelling reason to use the database, in general file systems are better suited for storing files. – David Aug 08 '16 at 12:53

1 Answers1

0

Using a database

You could use a database if your files aren't big. You would use a blob. But as the amount of files in your database grows, the power required grows.

Using the php functions

Make sure that the host has enabled uploading files and check the upload size limit that can be set by the host. Using this way you don't have to worry about file sizes.

Combination of both

You also could use a combination of both ways. Store the name and path in a database and then you can easily access it from there.

I hope this will help

DW_
  • 104
  • 1
  • 11
  • 2
    Good answer, however *"Using this way you don't have to worry about file sizes."* - that may not be the case if the host they're on (if they are hosted) may set uploaded file limits. – Funk Forty Niner Aug 08 '16 at 12:59
  • That's true but regardless of limits set by the host you can upload much bigger files than using a database. – DW_ Aug 08 '16 at 13:01