|
Posted by Manuel Lemos on 03/20/06 03:13
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" <mlemos@acm.org> wrote in message
> news:441DD5E8.4060400@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/
Navigation:
[Reply to this message]
|