splitting out Unirest\File and updating README

This commit is contained in:
Ahmad Nassri
2015-01-14 18:31:21 -05:00
parent ed2a2df982
commit be9bca1d5a
7 changed files with 64 additions and 66 deletions

19
src/Unirest/File.php Normal file
View File

@@ -0,0 +1,19 @@
<?php
namespace Unirest;
class File
{
/**
* Prepares a file for upload. To be used inside the parameters declaration for a request.
* @param string $path The file path
*/
public static function add($filename, $mimetype = '', $postname = '')
{
if (function_exists('curl_file_create')) {
return curl_file_create($filename, $mimetype = '', $postname = '');
} else {
return sprintf('@%s;filename=%s;type=%s', $filename, $postname ?: basename($filename), $mimetype);
}
}
}