0

I'm contemplating on how to store images in my new site.

Should I save the images directly to the database

OR

should I upload them to my server, while storing the path in my database?

Also, should it be the second choice, how does one retrieve the path of a file he uploaded previously?

Tom Granot
  • 1,840
  • 4
  • 22
  • 52
  • 2nd way is to go. There are tons of tutorials on how to do this. Even CI help provide example. – Kyslik Nov 09 '13 at 12:59

2 Answers2

1

You should definitely go with the second option as you can take advantage of the user's browser caching these images after the initial request. It also means your database wont be hit constantly for large files which is always a bad thing.

In CodeIgniter there are various parameters you can use to get the name / full file path to store in the database.

See http://ellislab.com/codeigniter%20/user-guide/libraries/file_uploading.html

Also take a look at this great SO question Storing Images in DB - Yea or Nay?

Community
  • 1
  • 1
SamV
  • 7,548
  • 4
  • 39
  • 50
0

I tried CI's own libraries , its good but not best, Image moo solved all my problems, uploading, resize, crop etc..

http://www.matmoo.com/digital-dribble/codeigniter/image_moo/

Mehmet Uyarovic
  • 304
  • 2
  • 9