rfc:curl-file-upload
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:curl-file-upload [2013/01/06 05:09] – [Optional] stas | rfc:curl-file-upload [2013/01/28 19:43] – vote close stas | ||
---|---|---|---|
Line 6: | Line 6: | ||
* First Published at: http:// | * First Published at: http:// | ||
* See also: https:// | * See also: https:// | ||
+ | * Implementation: | ||
This RFC discusses improvement for CURL file uploading option. | This RFC discusses improvement for CURL file uploading option. | ||
- | |||
===== Introduction ===== | ===== Introduction ===== | ||
Line 34: | Line 34: | ||
The file given to CurlFile will not be opened/read until curl_setopt() call. | The file given to CurlFile will not be opened/read until curl_setopt() call. | ||
- | ===== CurlFile | + | ===== CURLFile |
<code php> | <code php> | ||
- | class CurlFile | + | class CURLFile |
{ | { | ||
/** | /** | ||
Line 88: | Line 88: | ||
} | } | ||
</ | </ | ||
- | ===== Backward compatibility ===== | ||
- | In order to assure orderly transition to the use of the new API, the proposal | + | Also, the functional |
<code php> | <code php> | ||
- | curl_setopt($curl_handle, CURLOPT_UNSAFE_UPLOAD, true); | + | /** |
+ | * Create CURLFile object | ||
+ | * @param string $name File name | ||
+ | * @param string $mimetype Mime type, optional | ||
+ | * @param string $postfilename Post filename, defaults to actual filename | ||
+ | */ | ||
+ | function curl_file_create($name, $mimetype = '' | ||
+ | {} | ||
</ | </ | ||
- | In future versions, this capability may be removed completely. | + | This will create a new ```CURLFile``` object just as ```new CURLFile()``` would. |
+ | ===== Backward compatibility ===== | ||
- | ===== Optional ===== | + | A new option is introduced: '' |
- | - Ordered List ItemIf upstream cURL API permits, we could add in the future uploading files from string buffers, stream names, stream resources and such, which is now impossible with existing | + | |
- | - For people that are not comfortable with " | + | <code php> |
+ | curl_setopt($curl_handle, CURLOPT_SAFE_UPLOAD, | ||
+ | </ | ||
+ | |||
+ | In 5.6, @ option will be switched off by default, but can still be enabled by explicit curl_setopt setting, such as: | ||
<code php> | <code php> | ||
- | $data[' | + | curl_setopt($curl_handle, CURLOPT_SAFE_UPLOAD, |
</ | </ | ||
- | - It is possible to include validation of the file resource given in the constructor, | + | In future versions, this capability may be removed completely. |
+ | ===== Optional ===== | ||
+ | * If upstream cURL API permits, we could add in the future uploading files from string buffers, stream names, stream resources and such, which is now impossible with existing @-based API. The CurlFile API above will then be extended with required functions to support these, such as " | ||
+ | |||
+ | | ||
===== References ===== | ===== References ===== | ||
* CURL form API: http:// | * CURL form API: http:// | ||
* curl_setopt: | * curl_setopt: | ||
+ | * Pull request: https:// | ||
+ | |||
+ | ===== Vote ===== | ||
+ | |||
+ | Voting ended on Monday, January 28th 2013. In order to pass, the requirement is 50%+1 vote, since PHP core language is not changed. The result is: **ACCEPTED**. | ||
+ | |||
+ | < | ||
+ | title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
+ | |||
===== Changelog ===== | ===== Changelog ===== | ||
* 2013-01-05 First draft | * 2013-01-05 First draft | ||
+ | * 2013-01-06 Added pull req | ||
+ | * 2013-01-07 Added CURLOPT_SAFE_UPLOAD description | ||
+ | * 2013-01-12 Added curl_file_create() | ||
rfc/curl-file-upload.txt · Last modified: 2018/07/03 19:16 by stas