0

I had uploaded the image(blob field used) in DB.i want to show that image in pdf.how to write the code, please help me

3
Contributors
2
Replies
20
Views
4 Years
Discussion Span
Last Post by broj1
0

You shouldn't be storing your images in the Database. Yes, the blob column type exists, but that doesn't mean you should use it.

Database storage is more costly in terms of transactional (time, really) requirements and the complexity of your code. You'll be putting uneccessary load on your database server.

What you should be doing is storing the link to the images in the DB. You pull the link from the DB, and reference that using PHP's file methods.

For the PDF stuff, I'm not writing your code for you, but you should check out the FPDF Library.

Finally, since you seem like a newbie, don't use mysql_* functions in new code. They're no longer maintained and vulnerable to SQL injection. Use PDO, parameterised queries and do it properly :)

0

First thing, please do not start two threads in a very short time span for the same problem.

The problem I ran into was that fpdf's image method expects a file with an extension for supported images. This is why it is a problem to pass it a binary data from the db. A workaround could be to write the binary data into a temporary image file, pass the path to the file to the image method and then remove the file but this seems a bit awkward to me.

The easier method is obviously having images saved in filesystem and only paths (and other image data) in the db. Then using the image method is straightforward.

I suggest you post your question also on the fpdf forum.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.