I have a PHP form that will accept image uploads. For security purposes, it moves the image outside of the WWW root, saves it under a random filename, connects to a MySQL database, stores the filename with a unique record number, and returns that record number. To view the image, I have another PHP form that accepts a record number, looks up that record in the database, reads the image from the filename in that record, and displays it.
That all works fine. I use readfile() to output the contents of the image file to the screen. The problem is, there is a piece of text that also gets stored in the database record when the image is uploaded, and I want to display that along with the image. I've spent hours messing with header() and readfile() and content types and boundaries and output buffers and everything else, and if I try to display the image AND the text, I either get an internal server error or the image is broken. Or I get a huge encoded image string.
Ideally I'd like to have PHP spit out an HTML page with the image in it, but I'd settle for outputting the image and a line of plain text. What can I do?
Thanks