Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-16-2012, 09:37 PM   PM User | #1
cris-100
New to the CF scene

 
Join Date: Oct 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
cris-100 is an unknown quantity at this point
Question CURL POSTING multipart/form-data problem

Hello ,

First happy to join here its my first time

iam using curl to post data type of it

Content-Type: multipart/form-data; boundary=---------------------------25550903729072

-----------------------------25550903729072
Content-Disposition: form-data; name="textarea_21234"

"firstdata" <iamherehihowru>"
-----------------------------25550903729072
Content-Disposition: form-data; name="name"

samy

-----------------------------------------------

i can post without any issues just the problem that there is missing special characters <> also

i can encode the data before posting it - but the problem that it will be shown as encoded - and i cant decode it because i dont own the other side - its posting to other place

Here is code :
$link = "www.site.com"

$datatopost = array (

'textarea_21234' => "firstdata" <iamherehihowru>",
'name' => "samy",

);
$c=curl_init();
curl_setopt($c, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; rv:2.2) Gecko/20110201");
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($c, CURLOPT_TIMEOUT,15);
curl_setopt ($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, $datatopost);
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($c, CURLOPT_CONNECTTIMEOUT ,60);
curl_setopt($c, CURLOPT_TIMEOUT, 60);
curl_setopt($c, CURLOPT_HEADER, 0);
$crdata=curl_exec($c);
curl_close($c);



everything is good and able to post but when i check the textarea which my data should go to it i see it show this only

"firstdata"

and <iamherehihowru> total disapeared due to <> - problem that if i used urlencode as example it will be like this %3Ciamherehihowru%3E and this i dont want - i want it be shown as <> in the other side inside Textarea


Here also Request Header


User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: keep-alive
Content-Type: multipart/form-data; boundary=---------------------------3303192328350
Content-Length: 2836


--------------------

Response Header

HTTP/1.1 200 OK
Date: Tue, 16 Oct 2012 20:07:05 GMT
Vary: Accept-Encoding
Content-Type: text/html; charset=utf-8
Content-Encoding: gzip
Cache-Control: private
Age: 0
Transfer-Encoding: chunked
Connection: keep-alive




hope there is any solution
cris-100 is offline   Reply With Quote
Old 10-16-2012, 10:32 PM   PM User | #2
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,513
Thanks: 45
Thanked 439 Times in 428 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
You might want to urlencode the < and > characters and see if that works.

As for your boundary, I thought that was used for email not http / forms?
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Old 10-16-2012, 10:56 PM   PM User | #3
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,653
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Nope, boundaries can be viewed in any multipart message, so the form would be the same. Typically we don't need to worry about them from our level though as we receive the data parsed by the server who takes care of the messages for us (and other technologies like curl).
< and > are probably fine in the string itself; problem is they are not in the string. The only reason this doesn't throw a parser error is that it would see those as < and > comparisons to a constant. So you need to escape that " in the string: 'textarea_21234' => "firstdata\" <iamherehihowru>",, and then the < and > would be determined by the receiver (I'd expect they'd be fine).
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
tangoforce (10-17-2012)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:11 AM.


Advertisement
Log in to turn off these ads.