help with retrieval of binary data from mysql db
Posted: Thu Jan 11, 2007 7:40 am
hi all
i am storing binary data in mediumblob columns in my table. the uploaded files can be of any type, including (but not limited to) image/jpg, application/pdf, text/plan, etc.
please bare in mind that i am well aware of the advantages of using the filesystem for file uploads. in this scenario however, i need to store my files in the database. moving on...
when i display the contents of the table, i want to display/make-downloadble the file (blob) in each row. now each row has a column called file_type, which stores the file's Content-type (ie: image/jpg).
now if its an image, i want the image to be displayed right there in the table listing.
if the file is of some other type besides image or plain text, i want the user to just get a link to the file, that allows them to click on it which prompts for a download of the file (for pdf and word documents).
how do i achieve this?
i already have image displaying working with the <img src=... /> tag attribue calling a separate script that sets the header content-type and prints the file data, but this involves dumping the binary data into a file on the server first, which i am trying to avoid.
thanks
i am storing binary data in mediumblob columns in my table. the uploaded files can be of any type, including (but not limited to) image/jpg, application/pdf, text/plan, etc.
please bare in mind that i am well aware of the advantages of using the filesystem for file uploads. in this scenario however, i need to store my files in the database. moving on...
when i display the contents of the table, i want to display/make-downloadble the file (blob) in each row. now each row has a column called file_type, which stores the file's Content-type (ie: image/jpg).
now if its an image, i want the image to be displayed right there in the table listing.
if the file is of some other type besides image or plain text, i want the user to just get a link to the file, that allows them to click on it which prompts for a download of the file (for pdf and word documents).
how do i achieve this?
i already have image displaying working with the <img src=... /> tag attribue calling a separate script that sets the header content-type and prints the file data, but this involves dumping the binary data into a file on the server first, which i am trying to avoid.
thanks