supporting curl_file_create`

This commit is contained in:
thefosk
2014-01-08 19:05:22 -08:00
parent bf865a5c30
commit 1504e81ff1
3 changed files with 16 additions and 2 deletions

View File

@@ -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