1

I am working on a task to enable image uploading and auto-scaling(from full sized to thumbnail) by jQuery & PHP.

I can naturally come up with two approaches :

First, store both images as binary objects directly into MySQL; Second, store only urls to the images and keep the images somewhere on server.

The images are for everyone to view, so there are no security restrictions, as far as I know.

Personally I don't have any preference, however, at the end of the day, it is the business people that are going to manage the images as part of the system(CRUD). So I am wondering which seems to be a bit better for them?

Of course I am building a easy-to-use, visualize web interface for the staff to control the process, but I am not sure if that is enough. Lessons told me that if I don't think for the future and seek the most flexible approach, the I will probably screw myself sooner or later.

PS. The following link is what I've found so far, which is pretty cool, no flash involved :) Andrew Valum's ajax image upload jQuery plugin

Konerak
  • 39,272
  • 12
  • 98
  • 118
Michael Mao
  • 9,878
  • 23
  • 75
  • 91
  • Duplicate: http://stackoverflow.com/questions/3748/storing-images-in-db-yea-or-nay but surely, your end users do not have access to the mySQL database, do they? – Pekka Jun 03 '10 at 07:56
  • @Pekka : no, end users are customers who just view the images as part of their shopping experience. – Michael Mao Jun 03 '10 at 08:12

4 Answers4

5

Oh, how managers do like the "I know this too, I wanna play with it" thingies.

Store the images on a server. This way they can view/put/copy/modify the images the way they are used to: using Windows Explorer. They already know how to do it, and you won't have to write a lot of custom code afterwards to "I want to be able to X images ...".

Konerak
  • 39,272
  • 12
  • 98
  • 118
2

Like Konerak said, Store the images on a server.
But not in the database but just as a files.
And their names can be stored in the database, if needed.

That's plain, simple and natural way

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
2

First, store both images as binary objects directly into MySQL;

Noooo... no.. It's only going to take a month of PHBs uploading 10mp images for you to start crying uncle.

Second, store only urls to the images and keep the images somewhere on server.

Yes, a thousand times yes. Store the original file in one place and the latest edit in another.

Entendu
  • 1,235
  • 10
  • 12
1

IMO both are bad. Images in the DB cause connection pooling troubles, outside causes consistency nightmares.

For a first version I would just stick everything in the DB, this is good enough if you don't have too many users. If it's a success you could consider an integrated solution which handles both types of data, like JCR, for PHP you have jackalope. A bit complicated though, I wish there were better solutions.

JCR has WebDav bindings, so your managers can navigate the whole contents tree in explorer if they want. Not that I think that is a good idea though. One solution would be to let them play through WebDav, and always roll back the tx at the end :)

Alexander Torstling
  • 18,552
  • 7
  • 62
  • 74