Author Topic: [SOLVED] I need to send binary data from a Windows application to a web site (php script)  (Read 461 times)

0 Members and 1 Guest are viewing this topic.

Offline compiledTopic starter

  • Irregular
  • Posts: 8
    • View Profile
I need to send binary data from a Windows application to a site. I am used with compiled programming but I don't know much PHP.

Is it possible for a PHP script running on a Linux server to receive a package (binary string) of data of random size and store it to disk? Can anybody post a pseudo code (mock-up) PHP program for this so I can use it as starting point?

Thanks a lot.

Offline Garethp

  • Devotee
  • Posts: 989
  • Gender: Male
  • ($2b) || ! ($2b)
    • View Profile
Make the program save as a file and call it up with

$Data = fread("Filename");

Or some other method of file reading...
The Three Rules of Getting Assistance
1. Google first
2. Ask second
3. Then buy me some chocolate

Offline compiledTopic starter

  • Irregular
  • Posts: 8
    • View Profile
Make the program save as a file and call it up with

$Data = fread("Filename");

Or some other method of file reading...

Hi Garethp
I don't understand how a remote Linux server will know to upload a (specific) file from my local hard drive  ???

Offline bobbinsbro

  • Enthusiast
  • Posts: 384
  • Gender: Male
    • View Profile
try looking into php sockets.

Offline compiledTopic starter

  • Irregular
  • Posts: 8
    • View Profile
I am advancing.
However, I need to debug the POST package I send from my windows app. I think it is not properly formated because I get this:

Code: [Select]
[16-Nov-2008 17:22:23] PHP Warning: Missing boundary in multipart/form-data POST data in Unknown on line 0
Where/how can I see the HTTP POST request that my app sends?

Offline bobbinsbro

  • Enthusiast
  • Posts: 384
  • Gender: Male
    • View Profile
i have no idea  :D
but i found a program which may help:
http://www.fiddlertool.com/fiddler/

Offline compiledTopic starter

  • Irregular
  • Posts: 8
    • View Profile
Somebody suggested this code to see the POST but is working only partially:

if($_POST){
    $str = '';
    foreach($_POST as $P=>$p){
        $str .= "$P => $p\r\n";
    }
    $str .= "====================\r\n";
    $f = fopen('post.txt', 'a+');
    fwrite($f, $str);
    fclose($f);
    print('POST request saved to disk as post.txt<br>');   
}
else { print('No POST received!'); }

Offline compiledTopic starter

  • Irregular
  • Posts: 8
    • View Profile
Problem solved. Thank you very much for help.