cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

[win32] php-curl does not send correct multipart/form-data

From: <akorthaus_at_web.de>
Date: Wed, 09 Oct 2002 02:10:29 +0200

Hallo!

I'm using:
OS: Windows 2000 SP3
PHP: 4.2.2
Apache 2

PHP_Curl works perfectly, if I try that:

$formvars = "test=blabla";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https:/xxxxxxxxxxx.com/test.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $formvars);
echo curl_exec ($ch);
curl_close ($ch);

So I get

[_POST] => Array
(
[test] => blabla
)

but if I would like to use an array like

$formvars["test"] = "blabla";

I get

[_POST] => Array
(
[testýýýýÝÝÝÝÝÝÝÝ ] => blabla
)

What the hell is ýýýýÝÝÝÝÝÝÝÝ ?

I logged my TCP-traffic:

0001 00 90 1A 10 14 D3 00 40 F4 1E 47 68 88 64 11 00 .ü...Ó.@ô.GhÆd..
0002 0A 1F 01 25 00 21 45 00 01 23 32 19 40 00 80 06 ...%.!E..#2.@.¬.
0003 EA 9E 50 85 86 38 3E 43 C8 1C 0C 91 00 50 17 79 ê~P& 8>CÈ...P.y
0004 63 F8 66 86 AF A9 50 18 44 10 7E BC 00 00 50 4F cøf ß©P.D.~¼..PO
0005 53 54 20 2F 65 6E 76 2E 70 68 70 20 48 54 54 50 ST /env.php HTTP
0006 2F 31 2E 31 0D 0A 48 6F 73 74 3A 20 6B 6E 65 74 /1.1..Host: xxxx
0007 2D 73 79 73 74 65 6D 73 2E 64 65 0D 0A 50 72 61 xxxxxxx.com..Pra
0008 67 6D 61 3A 20 6E 6F 2D 63 61 63 68 65 0D 0A 41 gma: no-cache..A
0009 63 63 65 70 74 3A 20 69 6D 61 67 65 2F 67 69 66 ccept: image/gif
000A 2C 20 69 6D 61 67 65 2F 78 2D 78 62 69 74 6D 61 , image/x-xbitma
000B 70 2C 20 69 6D 61 67 65 2F 6A 70 65 67 2C 20 69 p, image/jpeg, i
000C 6D 61 67 65 2F 70 6A 70 65 67 2C 20 2A 2F 2A 0D mage/pjpeg, */*.
000D 0A 43 6F 6E 74 65 6E 74 2D 4C 65 6E 67 74 68 3A .Content-Length:
000E 20 31 34 30 0D 0A 45 78 70 65 63 74 3A 20 31 30 140..Expect: 10
000F 30 2D 63 6F 6E 74 69 6E 75 65 0D 0A 43 6F 6E 74 0-continue..Cont
0010 65 6E 74 2D 54 79 70 65 3A 20 6D 75 6C 74 69 70 ent-Type: multip
0011 61 72 74 2F 66 6F 72 6D 2D 64 61 74 61 3B 20 62 art/form-data; b
0012 6F 75 6E 64 61 72 79 3D 63 75 72 6C 63 5A 58 73 oundary=curlcZXs
0013 77 51 57 2F 47 67 32 31 6B 43 56 42 44 66 50 69 wQW/Gg21kCVBDfPi
0014 78 65 39 64 30 36 37 0D 0A xe9d067..

0001 00 90 1A 10 14 D3 00 40 F4 1E 47 68 88 64 11 00 .ü...Ó.@ô.GhÆd..
0002 0A 1F 00 B8 00 21 45 00 00 B6 32 1A 40 00 80 06 ...¸.!E..¶2.@.¬.
0003 EB 0A 50 85 86 38 3E 43 C8 1C 0C 91 00 50 17 79 ë.P& 8>CÈ...P.y
0004 64 F3 66 86 AF A9 50 18 44 10 60 A8 00 00 0D 0A dóf ß©P.D.`¨....
0005 2D 2D 63 75 72 6C 63 5A 58 73 77 51 57 2F 47 67 --curlcZXswQW/Gg
0006 32 31 6B 43 56 42 44 66 50 69 78 65 39 64 30 36 21kCVBDfPixe9d06
0007 37 0D 0A 43 6F 6E 74 65 6E 74 2D 44 69 73 70 6F 7..Content-Dispo
0008 73 69 74 69 6F 6E 3A 20 66 6F 72 6D 2D 64 61 74 sition: form-dat
0009 61 3B 20 6E 61 6D 65 3D 22 74 65 73 74 FD FD FD a; name="testýýý
000A FD DD DD DD DD DD DD DD DD 0B 22 0D 0A 0D 0A 62 ýÝÝÝÝÝÝÝÝ."....b
000B 6C 61 62 6C 61 0D 0A 2D 2D 63 75 72 6C 63 5A 58 labla..--curlcZX
000C 73 77 51 57 2F 47 67 32 31 6B 43 56 42 44 66 50 swQW/Gg21kCVBDfP
000D 69 78 65 39 64 30 36 37 2D 2D 0D 0A ixe9d067--..

there you can find:

name="testýýýýÝÝÝÝÝÝÝÝ."

but why? What is going wrong here? I need to use multipart/form-data
because I would like to transfer a binary string later on, but there is
the same Problem. It must have something to do with the array.

I don't know where to look for a solution so I asked hier, I hope you
can help me!

Thank you very much!

rgds.
Andreas

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2002-10-09