Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending binary data via HTTP POST

Status
Not open for further replies.

defens

Programmer
Mar 10, 2005
2
NL
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
 
You should make your Java give the transmission the MIME type application/octet-stream and that should settle the Java end. There is no further encoding necessary.
The PHP end allows you to see the RAW POST data. $GLOBALS["HTTP_RAW_POST_DATA"] contains the raw POSTed data from a request. Also available as $HTTP_RAW_POST_DATA in the global scope. This var, however, is only present if the encoding type is other than application/x-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top