View Full Version : PHP Image Upload

03-09-2003, 10:53 PM
ive got a question, i wanna upload a image and save it directly to mysql database ?

do i follow the common upload php rutine and then set the file to a variable and save it to a large blob on mysql ??


03-10-2003, 02:03 AM
Best way I found was to save the image to a directory, then just put the path to the image in the database.

03-10-2003, 01:24 PM
Yup nightfire, certainly saves on the overheads when you come to output the image.
Always did wonder why some people store non-changing data in a database - perhaps they just don't really know what a database is for.

03-12-2003, 10:08 AM
I've always wondered what image data is doing in a database. Could anyone give me a concrete example where storing in the DB makes more sense than storing the image's path?

03-12-2003, 10:59 AM
Well - databases are used rather than flatfile for when either - you change the data a lot or you need to search the data.

Now images - even if you change the image every 30 seconds, the overhead of database calls negates any good points there. So I assume most people who store images in databases have to search the binary data for something - so I guess they write some app that converts their ascii search term to binary and then checks the database - very long winded when you've got functions that can do that for flatfile stored images.

Or maybe they just put images in their databases because it sounds clever (in much the same way as IIS server sounds clever :D)

Ricardo - you might have guessed by now that we reccommend storing the image as a flatfile and just saving the path in the database.