Just for your info..I researched this a bit further..and with a little help
from the manual, the following works a treat.:
Cheers,
Craig
############################################################################
####
<?php
// Function to convert Hex to Binary
function hex2bin($hexdata)
{
for ($i=0;$i<strlen($hexdata);$i+=2) {
$bindata .= chr(hexdec(substr($hexdata,$i,2)));
}
return $bindata;
}
if(isset($_GET['id']) && !empty($_GET['id'])){
@include("inc/conn.php");
@$sqry_img = mssql_query("SELECT code,raw_data FROM smartmessages WHERE
code = '" . $_GET['id'] . "'");
if(mssql_num_rows($sqry_img) > 0)
{
$result = mssql_fetch_array($sqry_img);
Header ("Content-type: image/gif");
print hex2bin($result['raw_data']);
}
@mssql_free_result($sqry_img);
@mssql_close($conn);
}
?>
############################################################################
####
"Alexware" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 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:[EMAIL PROTECTED]
>
> 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" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > 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
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php