mirror of
https://github.com/php/php-src.git
synced 2025-08-19 08:49:28 +02:00
Fixed bug #48962 (cURL does not upload files with specified filename).
This commit is contained in:
parent
ec97c3c3e3
commit
82aeae4da1
1 changed files with 14 additions and 14 deletions
|
@ -1863,32 +1863,32 @@ type_conflict:
|
|||
* must be explicitly cast to long in curl_formadd
|
||||
* use since curl needs a long not an int. */
|
||||
if (*postval == '@') {
|
||||
char *type;
|
||||
char *type, *filename;
|
||||
++postval;
|
||||
|
||||
if ((type = php_memnstr(postval, ";type=", sizeof(";type=") - 1, postval + Z_STRLEN_PP(current)))) {
|
||||
*type = '\0';
|
||||
}
|
||||
if ((filename = php_memnstr(postval, ";filename=", sizeof(";filename=") - 1, postval + Z_STRLEN_PP(current)))) {
|
||||
*filename = '\0';
|
||||
}
|
||||
/* open_basedir check */
|
||||
if (php_check_open_basedir(postval TSRMLS_CC)) {
|
||||
RETVAL_FALSE;
|
||||
return 1;
|
||||
}
|
||||
error = curl_formadd(&first, &last,
|
||||
CURLFORM_COPYNAME, string_key,
|
||||
CURLFORM_NAMELENGTH, (long)string_key_len - 1,
|
||||
CURLFORM_FILENAME, filename ? filename : postval,
|
||||
CURLFORM_CONTENTTYPE, type ? type + sizeof(";type=") - 1 : "application/octet-stream",
|
||||
CURLFORM_FILE, postval,
|
||||
CURLFORM_END);
|
||||
if (type) {
|
||||
error = curl_formadd(&first, &last,
|
||||
CURLFORM_COPYNAME, key,
|
||||
CURLFORM_NAMELENGTH, l,
|
||||
CURLFORM_FILE, postval,
|
||||
CURLFORM_CONTENTTYPE, type + sizeof(";type=") - 1,
|
||||
CURLFORM_END);
|
||||
*type = ';';
|
||||
} else {
|
||||
error = curl_formadd(&first, &last,
|
||||
CURLFORM_COPYNAME, key,
|
||||
CURLFORM_NAMELENGTH, l,
|
||||
CURLFORM_FILE, postval,
|
||||
CURLFORM_END);
|
||||
|
||||
}
|
||||
if (filename) {
|
||||
*filename = ';';
|
||||
}
|
||||
} else {
|
||||
error = curl_formadd(&first, &last,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue