sending data via post

P

Peter

Hi,

Trying to figure out the puzzle pieces of a (possible) future project.

I'd like to send data to a server online.
I think I will use POST for that.
This will all happen inside an application.

I'm not quite sure if this is possible or if the remote server will be able
to accept it but I probably would like to send one big 'blob' of data that
then needs to be figured out at server side.

The problem may exist that the 'user' does not have a (working) internet
connection and I want to provide an easy way to save a file to floppy so
that the user can take the floppy walk to his neighbour, who does not have
the software installed, and send the data anyway.

So I was thinking of creating a html file that contains all the data I
wanted to POST and that then simply needs to be double clicked so that the
page is launched in internet explorer.
A text in that page would then say "click this link (or whatevere)" and when
that is done the data is sent via POST.

Is this at all possible ?
If yes, how would I have to format a html page to send a blob of data via
POST ?

Thanks,
a novice in this area of expertise.
 
J

Joshua Beall

Peter said:
Hi,

Trying to figure out the puzzle pieces of a (possible) future project.

I'd like to send data to a server online.
I think I will use POST for that.
This will all happen inside an application.

Well, you could do as you suggested, and have it in an HTML file, and make
it a self-submitting form with JS. But then you run into trouble if their
browser does not support JS, or has it disabled.

What you really need to do this in is some sort of server side scripting
language. This is really the wrong newsgroup for that, but here is a
snippet that will allow you to post an array of variables:

//build the post string
foreach($ata AS $key => $val)
$poststring .= urlencode($key) . "=" . urlencode($val) . "&";
// strip off trailing ampersand
$poststring = substr($poststring, 0, -1);

$host = "yoursite.com";
$port = 80; // 443 is using SSL; also prepend the host with "ssl://" when
you open the socket
$path = "/path/to/processing/script.php";

$fp = fsockopen($host, $port, $errno, $errstr, $timeout = 30);
if(!$fp) // If there is an error, tell us
echo "$errstr (error number $errno) \ntried to connect to
$host:$port\n\n{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}\n";
else
{
$length = strlen($poststring);
$serverStr = <<<EOT
POST $path HTTP/1.1
Host: $host
User-Agent: Put a user-agent here
Content-type: application/x-www-form-urlencoded
Content-length: $length
Connection: close\r\n
$poststring\r\n
EOT;
//send the server request
fputs($fp, $serverStr);
//loop through the response from the server
$response = '';
while(!feof($fp))
$response .= fgets($fp, 4096);

//close fp - we are done with it
fclose($fp);
}

If you have more questions about PHP, post to comp.lang.php. Lots of smart
guys in there.
 
L

Long - CM web hosting

: Hi,
:
: Trying to figure out the puzzle pieces of a (possible) future project.
:
: I'd like to send data to a server online.
: I think I will use POST for that.
: This will all happen inside an application.
:
You will need server-side support for form processing. If your web host supports
CGI or PHP, you can write your own handler. Alternatively, find a web host
that provides the service.

Long
www.webcharm.ca - content management web hosting
 
H

Hywel

Peter@Smart- said:
Hi,

Trying to figure out the puzzle pieces of a (possible) future project.

I'd like to send data to a server online.
I think I will use POST for that.
This will all happen inside an application.

I'm not quite sure if this is possible or if the remote server will be able
to accept it but I probably would like to send one big 'blob' of data that
then needs to be figured out at server side.

The problem may exist that the 'user' does not have a (working) internet
connection and I want to provide an easy way to save a file to floppy so
that the user can take the floppy walk to his neighbour, who does not have
the software installed, and send the data anyway.

So I was thinking of creating a html file that contains all the data I
wanted to POST and that then simply needs to be double clicked so that the
page is launched in internet explorer.
A text in that page would then say "click this link (or whatevere)" and when
that is done the data is sent via POST.

Is this at all possible ?
If yes, how would I have to format a html page to send a blob of data via
POST ?

The application is running on the desktop, then, not as a web
application? Why not have that application create a plain text file
containing the data, saved to floppy along with a mini-application (in
Delphi, for example), that when run simply reads the text file and posts
to a URL?
 
P

Peter

The application is running on the desktop, then, not as a web
application? Why not have that application create a plain text file
containing the data, saved to floppy along with a mini-application (in
Delphi, for example), that when run simply reads the text file and posts
to a URL?

I was trying to avoid making an extra applicaton actually,
hence the idea to format all in a html file somehow (if possible) so that if
double clicked the installed IE would be able to handle it and post it to
the server.
Server side is no issue (not mine anyway), a php script made by third party
will intercept
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top