Hey all,
I'm tearing my hair out over this one.. I'm using EasyPHP, and trying to
write a script which receives binary POST data from a client program of
mine. I've put together a simplified example which demonstrates the
problem. The data looks like this:
(String showing the length of the following binary)(Character
#10)(Binary data)
My PHP script looks like this:
<?
include('databasedef.php');
set_magic_quotes_runtime(0);
$chandle = mysql_pconnect($servername, $username, $password) or
die("FAIL");
mysql_select_db($database, $chandle) or die ("FAIL");
$handle=fopen("php://input","rb") or die("FAIL");
$c=fgets($handle,20);
$picture=mysql_real_escape_string(fread($handle,$c ));
$query="INSERT INTO ".$table." (Picture) VALUES ('".$picture."')";
mysql_db_query($database, $query) or die("Failed Query");
fclose($handle);
mysql_close($chandle);
?>
Although I get the right number of bytes in my MySQL database, they're
corrupted! What setting am I missing here? The files being stored are
less than 40k in a MEDIUMBLOB field.
Cheers,
Nicholas Sherlock