mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-09-11 10:56:29 +00:00
Fix curl @filename API deprecation error
This commit is contained in:
+8
-5
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user