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
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 ...".
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
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.
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 :)
精彩评论