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
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
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