supporting curl_file_create`
This commit is contained in:
@@ -113,6 +113,18 @@
|
||||
return Unirest::request(HttpMethod::PATCH, $url, $body, $headers, $username, $password);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a file for upload. To be used inside the parameters declaration for a request.
|
||||
* @param string $path The file path
|
||||
*/
|
||||
public static function file($path) {
|
||||
if (function_exists("curl_file_create")) {
|
||||
return curl_file_create($path);
|
||||
} else {
|
||||
return "@" . $path;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is useful for serializing multidimensional arrays, and avoid getting
|
||||
* the "Array to string conversion" notice
|
||||
|
||||
Reference in New Issue
Block a user