[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sheflug] Putting piccies in mysql/php



Craig Andrews  wrote:

> However, in order for the most common (I think) use of a MySQL image table to 
> be fulfilled, to output it via HTTP (using Perl, PHP, or something of your 
> own devising) simply output a 'content-type: ' header populated with the 
> filetype field, then just print the binary data.

    Well, after some tinkering about yesterday, I found that it is in
fact quite easy to deal with this. What I wanted was some sort of
system that would allow for an HTTP upload, introduction into DB via
PHP, and search/retrieval of images from the DB via PHP. It turns out
that your table reference is pretty much spot on. The idea is that the
file is uploaded somewhere (usually, /tmp/), you read from there and
insert it into the DB (with all the extra book-keeping infomration:
MIME-type, size, filename... That sort of thing). Then, the image can
be retrieved through a script that gets the id of the image's row
passed as a parameter (i.e., http://some.whe.re/piccy.php?id=323).
The piccy.php script then outputs the Content-type header, and then
shuffles the contents of the file using something like echo $pic or
somesuch.

   It is now working :-)

   José


-- 
José L Gómez Dans			PhD student
Tel: +44 114 222 5582			Radar & Communications Group
FAX; +44 870 132 2990			Department of Electronic Engineering
					University of Sheffield UK
___________________________________________________________________

Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html

  GNU the choice of a complete generation.