473,387 Members | 1,423 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,387 software developers and data experts.

help with Http POST data

Hello,
I'm new to web programming, and I've been looking all day on the web for
an answer to this question.

I'm trying to send some binary data, a relatively large amount (~128K), to a
PHP script from a wireless device that has TCP/IP sockets. So I'm sending
all of my data manually (ie ,"POST http://www.blah.com/process.php
HTTP/1.0\n").

I am able to send regular form data such as
"tireqty=3&oilqty=4&sparkqty=1&address=4204MainStr eet\n\n";
To do this I have a header for the content type like so: "Content-Type:
application/x-www-form-urlencoded\n";"

I have even encoded my data in base64 so that it is ready to send as ASCII.
This data is broken into chunks where after each 76 characters there is a
\r\n line break. I read that I needed to do that.

But HOW do I send it? If I send it as form data, with variables, then it
only receives the data up until the first line break. I tried changing the
content type to "Content-Type: application/octet-stream\n", thinking that I
could just send the data without form variables, but then how do you access
that from PHP? For example I tried sending the string "data=XXXYYY" where
XXXYYY is my base64 encoded data, but it didn't work.

I can't seem to find any good documentation about this. Which Content-Type
shouldI be using? Can I use octet-streams and still have the data connected
to php variables? It's very confusing.

Thanks for any pointers.

B



Mar 19 '06 #1
5 3221
I send the stuff as form data all the time (although not that volume/size).
No chunking, no content-type. Yr base64 encoding makes it an ascii
transmission.

Use "extract ($HTTP_POST_VARS)" at the top of yr php receiver script to get
at what was the form vars. Really simple. Try it with a small volume to see
if the size breaks the logic, which I don't think it will for POST data.
HTH.

AS
"Bint" <Bi**@igm.com> wrote in message
news:6%***************@tornado.texas.rr.com...
Hello,
I'm new to web programming, and I've been looking all day on the web
for an answer to this question.

I'm trying to send some binary data, a relatively large amount (~128K), to
a PHP script from a wireless device that has TCP/IP sockets. So I'm
sending all of my data manually (ie ,"POST http://www.blah.com/process.php
HTTP/1.0\n").

I am able to send regular form data such as
"tireqty=3&oilqty=4&sparkqty=1&address=4204MainStr eet\n\n";
To do this I have a header for the content type like so: "Content-Type:
application/x-www-form-urlencoded\n";"

I have even encoded my data in base64 ...

Mar 19 '06 #2
Bint wrote:
I'm trying to send some binary data, a relatively large amount
(~128K), to a PHP script from a wireless device that has TCP/IP
sockets. So I'm sending all of my data manually (ie ,"POST
http://www.blah.com/process.php HTTP/1.0\n").


A basic example can be viewed here:

http://playground.jwscripts.com/postdata.phps
HTH;
JW

Mar 19 '06 #3
Hello,

on 03/18/2006 09:56 PM Bint said the following:
I have even encoded my data in base64 so that it is ready to send as ASCII.
This data is broken into chunks where after each 76 characters there is a
\r\n line break. I read that I needed to do that.
No, that is not the way to post binary files.

But HOW do I send it? If I send it as form data, with variables, then it
only receives the data up until the first line break. I tried changing the
content type to "Content-Type: application/octet-stream\n", thinking that I
could just send the data without form variables, but then how do you access
that from PHP? For example I tried sending the string "data=XXXYYY" where
XXXYYY is my base64 encoded data, but it didn't work.

I can't seem to find any good documentation about this. Which Content-Type
shouldI be using? Can I use octet-streams and still have the data connected
to php variables? It's very confusing.


You need to post it like normal forms with file fields. It must be sent
with multipart/form-data content type and then you need to compose a
multipart form body.

You may also want to take a look at this http client class that can post
files this way transparently:

http://www.phpclasses.org/httpclient
--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
Mar 19 '06 #4
What I have is not a file, it is just an array of binary data. The device
doesn't have a file system. I need to be able to send the binary data
without it being in a file.

Bint
"Manuel Lemos" <ml****@acm.org> wrote in message
news:44**************@acm.org...
Hello,

on 03/18/2006 09:56 PM Bint said the following:
I have even encoded my data in base64 so that it is ready to send as
ASCII.
This data is broken into chunks where after each 76 characters there is a
\r\n line break. I read that I needed to do that.


No, that is not the way to post binary files.

But HOW do I send it? If I send it as form data, with variables, then it
only receives the data up until the first line break. I tried changing
the
content type to "Content-Type: application/octet-stream\n", thinking that
I
could just send the data without form variables, but then how do you
access
that from PHP? For example I tried sending the string "data=XXXYYY"
where
XXXYYY is my base64 encoded data, but it didn't work.

I can't seem to find any good documentation about this. Which
Content-Type
shouldI be using? Can I use octet-streams and still have the data
connected
to php variables? It's very confusing.


You need to post it like normal forms with file fields. It must be sent
with multipart/form-data content type and then you need to compose a
multipart form body.

You may also want to take a look at this http client class that can post
files this way transparently:

http://www.phpclasses.org/httpclient
--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

Mar 19 '06 #5
Hello,

on 03/19/2006 08:41 PM Bint said the following:
What I have is not a file, it is just an array of binary data. The device doesn't have a file system. I need to be able to send the binary data
without it being in a file.
It doesn't matter. What matters is that for you to send the data you can
emulate the submission of a form with a file field. Don't worry, the
class takes care of that for you.

Just take a look at the test_http_post.php example and see the PostFiles
array . It has one element like this:

"userfile"=>array(
"Data"=>$your_binary_data_string,
"Name"=>"invent_a_file_name",
"Content-Type"=>"automatic/name",
),
"Manuel Lemos" <ml****@acm.org> wrote in message
news:44**************@acm.org...
Hello,

on 03/18/2006 09:56 PM Bint said the following:
I have even encoded my data in base64 so that it is ready to send as
ASCII.
This data is broken into chunks where after each 76 characters there is a \r\n line break. I read that I needed to do that.

No, that is not the way to post binary files.

But HOW do I send it? If I send it as form data, with variables, then it only receives the data up until the first line break. I tried changing
the
content type to "Content-Type: application/octet-stream\n", thinking that I
could just send the data without form variables, but then how do you
access
that from PHP? For example I tried sending the string "data=XXXYYY"
where
XXXYYY is my base64 encoded data, but it didn't work.

I can't seem to find any good documentation about this. Which
Content-Type
shouldI be using? Can I use octet-streams and still have the data
connected
to php variables? It's very confusing.

You need to post it like normal forms with file fields. It must be sent
with multipart/form-data content type and then you need to compose a
multipart form body.

You may also want to take a look at this http client class that can post
files this way transparently:

http://www.phpclasses.org/httpclient

--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
Mar 20 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
2
by: Keith Selbee | last post by:
I am trying to submit data to a webpage in the form of a post and my code is below. It is a function that takes a url and the post content as strings and then performs the post. But as soon as I...
0
by: hagar | last post by:
Hi all, I have a problem which I can not understand why this is happening! Debugging this I actually see that it grabs first record then when stepping through code to the line rsImportTo.AddNew...
1
by: devranger | last post by:
Hello, I am in the process of learning PHP CURL and in doing some test examples I am having some issues with CURL that I do not fully understand. I am doing a test to use CURL to post and return...
6
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
2
by: helraizer1 | last post by:
Hi folks, I have a file for my chatbox called data.line, which the posts are in the layout CHATBOXTEXT 7 username=helraizer 1202416953
4
by: ShutterMan | last post by:
I have a JSON object as below (data is from SQL Server Northwind Database). But doing an eval on it returns an error "unterminated string constant" or such. Can someone help me pinpoint the...
12
by: =?Utf-8?B?ZGdvdw==?= | last post by:
I designed a "contact_us" page in visual web developer 2005 express along with EW2 after viewing tutorials on asp.net's help page. Features work like they should, but I cannot figure out how to...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.