473,386 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Binary post data

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
2 3103
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ot?vio | last post by:
Hi! I'm havin a problem about sending a binary file with fsockopen. My problem is solved when i do: -------------------->8------CODE----------------------------- <form...
4
by: Paul | last post by:
Hi, (First apologies if this is not the most relevant place to post this but I wasn't sure of where was and I am writing my app in VB.) I'm attempting to parse a binary file for which I have...
6
by: Sebastian Kemi | last post by:
How should a write a class to a file? Would this example work: object *myobject = 0; tfile.write(reinterpret_cast<char *>(myobject), sizeof(*object)); / sebek
6
by: someone | last post by:
Suppose that I have a class in an assembly that is delivered to the user, what can I do to change the class so that it doesn't break the binary compatibility? That is, user application can run...
5
by: nickisme | last post by:
Hi - sorry for the possibly stupid question, but I'm still a wee starter on c++... Just wondering if there's a quick way to convert data into binary strings... To explain, I'm trying to convert...
4
by: Tarique Jawed | last post by:
Alright I needed some help regarding a removal of a binary search tree. Yes its for a class, and yes I have tried working on it on my own, so no patronizing please. I have most of the code working,...
7
by: John Dann | last post by:
I'm trying to read some binary data from a file created by another program. I know the binary file format but can't change or control the format. The binary data is organised such that it should...
4
by: Schwarty | last post by:
I hope I posted this to the correct group. If not, please let me know and I will get it posted in the correct section. I have a web application developed in ASP.NET using C# for the code behind....
11
by: Freddy Coal | last post by:
Hi, I'm trying to read a binary file of 2411 Bytes, I would like load all the file in a String. I make this function for make that: '-------------------------- Public Shared Function...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.