Click to See Complete Forum and Search --> : Sending binary data via HTTP


defens
March 11th, 2005, 03:45 AM
Hi all. Have the following hypothetical situation.

I have a small java-app embedded in a phone with http lib. I want to send small chunks of binary data (not text!) to my php script, that has to store this data in some way.

I assume using HTTP POST on the java side, but what should this HTTP header look like and what do i use on the PHP side... The java unit has no mime coding or specific libs.

In other words: how to send binary data by HTTP and how to receive them.

Thanks for any reflections...

Martin Beek

bigBA
March 11th, 2005, 10:06 AM
you may have a look at this:
http://www.php.net/manual/en/features.file-upload.php#features.file-upload.post-method
implement it in a simple script and look up the http headers sent by the browser.

you can do this by using IE and this little plugin:
http://www.blunck.info/iehttpheaders.html

just a guess (havn't done it yet)
but if it is just minor binary data (less than 256 bytes (i think this is the maximum length of a url)) you can base64encode your data and send it via get.

or post if it is more than you maybe can use this one:

POST /script.php HTTP/1.1
Host: www.server.net
Content-Length: LENGTH OF THE CONTENT

BINDATA=base64encoded_data

in the script just base64decode the content of the BINDATA variable