Fix curl @filename API deprecation error

This commit is contained in:
Zach Borboa
2014-03-03 23:17:03 -08:00
parent 1559daa462
commit 258a3c396c
+8 -5
View File
@@ -208,16 +208,19 @@ class Curl {
$data = http_build_multi_query($data);
}
else {
// Fix "Notice: Array to string conversion" when $value in
// curl_setopt($ch, CURLOPT_POSTFIELDS, $value) is an array
// that contains an empty array.
foreach ($data as $key => $value) {
// Fix "Notice: Array to string conversion" when $value in
// curl_setopt($ch, CURLOPT_POSTFIELDS, $value) is an array
// that contains an empty array.
if (is_array($value) && empty($value)) {
$data[$key] = '';
}
// Fix "curl_setopt(): The usage of the @filename API for
// file uploading is deprecated. Please use the CURLFile
// class instead".
else if (is_string($value) && strpos($value, '@') === 0) {
if (function_exists('curl_file_create')) {
$data[$key] = new CURLFile($value);
if (class_exists('CURLFile')) {
$data[$key] = new CURLFile(substr($value, 1));
}
}
}