Re: Reading binary http post

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

 



This is actually not a solution as is not solving Dirk's problem. The 'A' will make the isset($_POST['data']) to be always true. Another thing is that the $_POST['data'] is still not containing the binary code that is expected as the PHP will get the & and will start a new variable

A solution will be the base64_encode() which is the safest way to transport binary data over the net. Another one will be a simple rawurlencode() which is supposed to solve exactly this problem and on the server you shouldn't do any decode after. However I can't grant you that your binary will correctly survive.



----------------------------
Cristian MARIN - cristic@xxxxxxxxxxxxxxxxxx <mailto:cristic@xxxxxxxxxxxxxxxxxx>
Developer Designers Department
InterAKT Online (www.interaktonline.com <http://www.interaktonline.com>


Dan Baker wrote:
"Dirk Vanden Boer" <dirk.vdb@xxxxxxxxx> wrote in message news:67.98.45151.2CE5BF34@xxxxxxxxxxxxxxx
Hi,

I have a C++ application that posts binary data to a php script that I created using libcurl. Everything works fine except when my binary data happens to start with the '&' symbol. In that case I can't read the http post data (isset returns false).

The post argument then looks like data=&ÑÚA
Reading the post is done like this:
if (isset($_POST['data'])
Is there a way to fix this problem?

A quick-n-dirty method is to prepend a known letter to the data, like an "A":
data=A&ÑÚA
Then, ignore the first character of the data, since it is known to be the "A" character.

I would think that if the data contains an "&" in the middle of the data, you may not be getting all the data.
"data=ABC&xyz=123"
$_POST['data'] = "ABC"
$_POST['xyz'] = "123"

DanB

[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