Inserting modified image into a database

See all posts See thread Reply

Re: Inserting modified image into a database new!
by Rocket Dog, 15 years, 9 months ago
In looking at your example code, if I understand you correctly we would need to call the process() function twice if we want to save the file to the server as well as to the database.

First we modify the file and use process($directory) to save the file to the server.

Then, we modify the file again as we did before, and use process() to save the contents of the file to the database as a BLOB.

So we're writing the same code twice (unless of course we create a single function to handle the image modification, and then call that function twice.) Let me know if I understand that correctly.

BTW, the only reason I'm saving the file to the database is because it's part of my masters degree project to compare image retrieval performance between the server and the database. But normally I would never do that in practice.Reply
Re: Inserting modified image into a database new!
by colin, 15 years, 9 months ago
Strictly speaking, you would need to call process() twice to store the image on file and in the database.

But in fact, you can simply retrieve the image content as in my code example, calling process() without an argument, and then you can save the return value to the database, and dump it to the disk too, using for instance imagepng() or any other PHP image functions.

Sa you can call process() once, and save the image content several times if you wish.Reply