We have faced some issues with posting form details using cURL module of php.
A form having file upload option was not posted correctly.
The content type is multi-part/form-data for this form.
The below line of code will set the post fields for the curl session.
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fiels);
The $post_fields can be specified either as querystring parameters or as an associative array.
Initially we had specified the $post_fields as querystring paramter as $post_fields="field1=value1&field2=value2";
But this approach didn't work for the multi-part/form-data forms.
It works fine after changing this code using an associative array as below.
$post_fields = array("field1" => "value1", "field2" => "value2");
More Articles...
Search This Blog
Blog Archive
-
▼
2009
(257)
-
▼
December
(13)
- Released javascript widget for showing New Year Qu...
- Released eBooks for learning Software Testing and QTP
- Added more questions in our online Quiz
- News Letter
- Released Free widget for showing Christmas Quotes
- Use associative array instead of using querystring...
- Clearing Cache in phpBB forum
- Boost your adSense revenue by using Category filter.
- New blog from QualityPoint for showing latest News...
- Parsing webpage using php DOM.
- Setting UserAgent for php curl session to avoid 50...
- Latest Articles for learning Web Development usin...
- Removing Last Character in a String
-
▼
December
(13)
Get an AI course for just Rs 300 ($8) - A free option is also available

AI Course | Bundle Offer | Unlocking AI | Dream Big | Listen to Dream Big
Today's Deals | Timesheet | Products | SQL ebook | Earn 50% commission
About | Privacy | Follow | TOS | WhatsApp | Contact
I may earn a commission from Amazon affiliate links
No comments:
Post a Comment