@@ -190,9 +190,9 @@ public function addResponseHeaderLine($curl, $header_line)
190190
191191 if ($ trimmed_header === "" ) {
192192 $ this ->response_header_continue = false ;
193- } else if (strtolower ($ trimmed_header ) === 'http/1.1 100 continue ' ) {
193+ } elseif (strtolower ($ trimmed_header ) === 'http/1.1 100 continue ' ) {
194194 $ this ->response_header_continue = true ;
195- } else if (!$ this ->response_header_continue ) {
195+ } elseif (!$ this ->response_header_continue ) {
196196 $ this ->response_headers [] = $ trimmed_header ;
197197 }
198198
@@ -232,7 +232,19 @@ protected function preparePayload($data)
232232 $ this ->setOpt (CURLOPT_POST , true );
233233
234234 if (is_array ($ data ) || is_object ($ data )) {
235- $ data = http_build_query ($ data );
235+ $ skip = false ;
236+ foreach ($ data as $ key => $ value ) {
237+ // If a value is an instance of CurlFile skip the http_build_query
238+ // see issue https://github.com/php-mod/curl/issues/46
239+ // suggestion from: https://stackoverflow.com/a/36603038/4611030
240+ if ($ value instanceof \CurlFile) {
241+ $ skip = true ;
242+ }
243+ }
244+
245+ if (!$ skip ) {
246+ $ data = http_build_query ($ data );
247+ }
236248 }
237249
238250 $ this ->setOpt (CURLOPT_POSTFIELDS , $ data );
@@ -499,28 +511,28 @@ public function setOpt($option, $value)
499511 return curl_setopt ($ this ->curl , $ option , $ value );
500512 }
501513
502- /**
503- * Get customized curl options.
504- *
505- * To see a full list of options: http://php.net/curl_getinfo
506- *
507- * @see http://php.net/curl_getinfo
508- *
509- * @param int $option The curl option constante e.g. `CURLOPT_AUTOREFERER`, `CURLOPT_COOKIESESSION`
510- * @param mixed $value The value to check for the given $option
511- */
514+ /**
515+ * Get customized curl options.
516+ *
517+ * To see a full list of options: http://php.net/curl_getinfo
518+ *
519+ * @see http://php.net/curl_getinfo
520+ *
521+ * @param int $option The curl option constante e.g. `CURLOPT_AUTOREFERER`, `CURLOPT_COOKIESESSION`
522+ * @param mixed $value The value to check for the given $option
523+ */
512524 public function getOpt ($ option )
513525 {
514526 return curl_getinfo ($ this ->curl , $ option );
515527 }
516528
517- /**
518- * Return the endpoint set for curl
519- *
520- * @see http://php.net/curl_getinfo
521- *
522- * @return string of endpoint
523- */
529+ /**
530+ * Return the endpoint set for curl
531+ *
532+ * @see http://php.net/curl_getinfo
533+ *
534+ * @return string of endpoint
535+ */
524536 public function getEndpoint ()
525537 {
526538 return $ this ->getOpt (CURLINFO_EFFECTIVE_URL );
0 commit comments