File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ public function sendRequest(
9090 if ($ method == 'POST ' ) {
9191 curl_setopt ($ curl , CURLOPT_POST , 1 );
9292 if ($ isFile ) {
93+ $ data ['file ' ] = $ this ->getCurlValue ($ data ['file ' ]);
9394 curl_setopt ($ curl , CURLOPT_POSTFIELDS , $ data );
9495 } else {
9596 curl_setopt ($ curl , CURLOPT_POSTFIELDS , json_encode ($ data ));
@@ -122,4 +123,19 @@ public function sendRequest(
122123
123124 return $ data ;
124125 }
126+
127+ /**
128+ * If necessary, replace curl file @ string with a CURLFile object (for PHP 5.5 and up)
129+ *
130+ * @param string $fileString The string in @-format as it is used on PHP 5.4 and older.
131+ * @return \CURLFile|string
132+ */
133+ protected function getCurlValue ($ fileString )
134+ {
135+ if (!function_exists ('curl_file_create ' )) {
136+ return $ fileString ;
137+ }
138+
139+ return curl_file_create (substr ($ fileString , 1 ));
140+ }
125141}
You can’t perform that action at this time.
0 commit comments