Re: correctly reading binary data from http post

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As I read through my first email again I see I didn't write clearly
what I intended, sorry for this. I already have an application that
sends binary data with requests like the one mentioned before. Now I
need to parse those requests using PHP. Since the content-type is
multipart/form-data, neither php://input nor $HTTP_RAW_POST_DATA
works.
That request type was taken from an example from w3c webpage
(http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4), so I
believe there will not be much trouble parsing them.

On 9/15/06, Arpad Ray <arpad@xxxxxxxxxxx> wrote:
The fact you're accessing it as an element of $HTTP_POST_VARS (which
should be $_POST anyway) means it's expected to be URL encoded.
Instead set your request Content-Type to octet-stream and grab the whole
post body at once.

eg.

// To send...

$c = stream_context_create(
    array(
        'http' => array(
            'method' => 'post',
            'header' => 'Content-Type: application/octet-stream',
            'content' => "whatever you want \x00 here"
        )
    )
);
file_get_contents('http://example.com/foo.php', false, $c);

// To receive

$data = file_get_contents('php://input');



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux