Hello world, Can you please help me.I have a blob field and want to insert and read image, but don't know how to do that.I want to insert data with images into mysql db and then read that in php. Thank a lot
There are hardly any good reasons to store image in a database although it is technically possible. It is probably a better idea to store them in the filesystem and keep reference records in the database, containing filenames etc. If you allow people to upload those images make sure you store them outside of the webtree for security reasons. Use a wrapper to display them to the browser: ... // First tell the browser we are going to send an image, in this case asumme it is a .PNG image Header('Content-type: image/png'); // send it to output, assume $imagefile contains the full path to our image readfile($imagefile); ... Code (markup): If the image is stored in a database you will need to store it in a way that you can use imagecreatefromstring() to recreate the image from it. Read the comments on this php.net page, there is an example on how to read it from a db.