Re[2]: [PHP] Imgs in Database

From: Date: Wed, 04 Jun 2003 16:35:57 +0000
Subject: Re[2]: [PHP] Imgs in Database
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-150214@lists.php.net to get a copy of this message
Hello Craig & All, As far I know, you can just echo it to a file and you will get the image file. Of course don't forget the extention. Just a simple "for" cycle can do it for you (inside a select). e.g.: $query = "select bin_data,filetype from binary_data"; $result = mysql_query($query); $numofrecords = mysql_num_rows($result); for ($i=1; $i<=$numofrecords; $i++) { $type = $ratas->filetype; // used for type marking some how // do open a file with name +$i+content type (e.g. gif or jpg or whatsoever) $datas = mysql_fetch_object($result); // the picture stored in the database $data = $datas->bin_data; // echo it to the file opened previously // close the file } If I would meet this, I would try this. Any comments? -- Best regards, Alex mailto:alexware@fibermail.hu Wednesday, June 4, 2003, 1:26:47 PM, You wrote: > An Image file is just text typically.... > If you know the format of the images it should be a case of extracting the > 'text' that is the file and sending the appropriate headers... > ----- Original Message ----- > From: "Craig" <craig@deconstructor.net> > To: <php-general@lists.php.net> > Sent: Wednesday, June 04, 2003 12:09 PM > Subject: [PHP] Imgs in Database >> Im converting a site from asp to php, Its db driven and some images are >> stored in the db. >> >> The previous developer stored the image files in a text string format, Im >> assuming I have to convert the text back into a binary format, anyone had >> any experience with this or can shed some light on this for me? >> >> Regards, >> >> Craig

« previous php.general (#150214) next »