By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,304 Members | 1,242 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,304 IT Pros & Developers. It's quick & easy.

Binary post data

P: n/a
After extensive googling I'm still stuck :(

I have a clientprogram that needs to call a php script (via an Apache2
webserver) and pass binary parameters as POST data - typically around
30K in size - nb this is not a 'file upload'. The client prepares a
multipart/form-data document and targets the php script. Although the
multipart form is clearly being interpreted correctly in sa far as
POST variables are being set, PHP only provides data up to the first
NULL byte - the remainder appears to be discarded.

Using a wire sniffer I can see the HTTP document being sent(which
looks correct). I'm using PHP 4.3.6 and Apache 2.0.49-r1. I've seen
references to a bug in previous versions of PHP, but they appear to
have been fixed long ago. One thing I have notioced is that the
client doesn't add a Content-Type header within the data boundary :

--------061404110049824
Content-Disposition: form-data; name="data"
BZh11AY&SYU...
<snip 30K binary data>.......

--------061404110049824
is it supposed (or even allowed) to do so (add a Content-Type header
within a boundary)?

Any help would be appreciated.

Thanks

Mark
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
MarkH wrote:

Using a wire sniffer I can see the HTTP document being sent(which
looks correct). I'm using PHP 4.3.6 and Apache 2.0.49-r1. I've seen
references to a bug in previous versions of PHP, but they appear to
have been fixed long ago. One thing I have notioced is that the
client doesn't add a Content-Type header within the data boundary :

--------061404110049824
Content-Disposition: form-data; name="data"
BZh11AY&SYU...
<snip 30K binary data>.......

--------061404110049824

IIRC, if you were to try a file upload you'd see that it is normally base64
encoded - i.e. does not contain null bytes in-transit.

HTH

C.

Jul 17 '05 #2

P: n/a
Colin McKinnon <co**************@andthis.mms3.com> wrote in message news:<ca*******************@news.demon.co.uk>...
MarkH wrote:

Using a wire sniffer I can see the HTTP document being sent(which
looks correct). I'm using PHP 4.3.6 and Apache 2.0.49-r1. I've seen
references to a bug in previous versions of PHP, but they appear to
have been fixed long ago. One thing I have notioced is that the
client doesn't add a Content-Type header within the data boundary :

--------061404110049824
Content-Disposition: form-data; name="data"
BZh11AY&SYU ...
<snip 30K binary data>.......

--------061404110049824

IIRC, if you were to try a file upload you'd see that it is normally base64
encoded - i.e. does not contain null bytes in-transit.


It seems the Content-Type thing was a red herring. PHP creates a
temporary file (file name in $param_name ... not
$_POST['param_name']). You then use fopen to read the file and it is
automatically deleted at the end of execution.

Mark
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.