This is a discussion on Going crazy about binary post within the PHP Language forums, part of the PHP Programming Forums category; Hey all, I'm tearing my hair out over this one.. I'm using EasyPHP, and trying to write a ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
Puzzling. It might have something to do with the
encoding. What kind of files are you inserting? More likely, though, it is a bug specific to EasyPHP, perhaps due to compilation issues. Can you try running your code on a Linux box? Felix |
|
|||
|
Felix wrote:
> Puzzling. It might have something to do with the > encoding. What kind of files are you inserting? GIF images. It's got me beat as well. > More likely, though, it is a bug specific to > EasyPHP, perhaps due to compilation issues. > Can you try running your code on a Linux box? I don't have one available.. I'll try updating the individual components of EasyPHP. Cheers, Nicholas Sherlock |