extracting MySQL Image Data

admin

Administrator
Staff member
I have searched the internet inside and out. with no luck except for the following script that is listed below. I am trying to do one of the two things.

1) extract data and write the data to file. This would allow me to extract the data into files on the server when new recorders are added. I have explored exec() & passthru() to accomplish this feat.

or

2) extract data and write to html. I looked up all information and have tried them all and nothing is working.

I have tried the following:

1) The binary is good becuase I can use a windows program to extract the data and write to the file. Then the picture views perfect.

2) The query is returning the correct record.

3) The raw data could be printed directly to html.

4) I have tried adding headers for filename, filetype and filesize.

I still always get a big red X for the image. But If I check the properties of the image it has jpeg Image so I know the header for type is making it to the html.

Can anyone help me....

Thanks
Dennis
I appreciate any help!
<!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->

Please Note: THE PORT ON THE MYSQL ADDRESS IS REQUIRED AND IS SHOWN IN THE FOLLOWING CODE AS :####.

<?php

// getdata.php3 - by Florian Dittmer <[email protected]>
// Example php script to demonstrate the direct passing of binary data
// to the user. More infos at <!-- m --><a class="postlink" href="http://www.phpbuilder.com">http://www.phpbuilder.com</a><!-- m -->
// Syntax: getdata.php3?id=<id>

if($id)
{
@mysql_connect("XXX.XXX.XXX.XXX:####","XXXXX","XXXXXXXX");
@mysql_select_db("xxxop");
$query = "select LASTPIC, filetype, filename, filesize from FABSCHED where CLASSKEY = 100";
$result = @mysql_query($query);

$data = @mysql_result($result,0,"LASTPIC");
$filen = @mysql_result($result,0,"filename");
$type = @mysql_result($result,0,"filetype");

Header("Content-type: $type");
echo $data;
}

?>
 
Back
Top