Going crazy about binary post

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-02-2005
Nicholas Sherlock
 
Posts: n/a
Default Going crazy about binary post

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
Reply With Quote
  #2 (permalink)  
Old 03-02-2005
Felix
 
Posts: n/a
Default Re: Going crazy about binary post

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

Reply With Quote
  #3 (permalink)  
Old 03-02-2005
Nicholas Sherlock
 
Posts: n/a
Default Re: Going crazy about binary post

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
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 10:50 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0