diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2008-11-27 17:00:04 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2008-11-27 17:00:04 +0000 |
commit | d741138a4639adb14cb31ea519ded0e0432c9e9a (patch) | |
tree | 6315b54a12d563f3cb353df2486bee87e8019a16 | |
parent | 12e27a70147348db7e515e3787ce14b91c824c20 (diff) | |
download | php-git-d741138a4639adb14cb31ea519ded0e0432c9e9a.tar.gz |
Fixed bug #46696 (cURL fails in upload files with specified content-type)
-rw-r--r-- | ext/curl/interface.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 0e9ac1ee67..982748092f 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -1582,17 +1582,37 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu * must be explicitly cast to long in curl_formadd * use since curl needs a long not an int. */ if (*postval == '@') { + char *type; ++postval; + + if ((type = php_memnstr(postval, ";type=", sizeof(";type=") - 1, postval + strlen(postval)))) { + *type = '\0'; + } /* safe_mode / open_basedir check */ if (php_check_open_basedir(postval TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(postval, "rb+", CHECKUID_CHECK_MODE_PARAM))) { + if (type) { + *type = ';'; + } RETVAL_FALSE; return 1; } - error = curl_formadd(&first, &last, + if (type) { + type++; + error = curl_formadd(&first, &last, + CURLFORM_COPYNAME, string_key, + CURLFORM_NAMELENGTH, (long)string_key_len - 1, + CURLFORM_FILE, postval, + CURLFORM_CONTENTTYPE, type, + CURLFORM_END); + *(type - 1) = ';'; + } else { + error = curl_formadd(&first, &last, CURLFORM_COPYNAME, string_key, CURLFORM_NAMELENGTH, (long)string_key_len - 1, - CURLFORM_FILE, postval, + CURLFORM_FILE, postval, CURLFORM_END); + + } } else { error = curl_formadd(&first, &last, CURLFORM_COPYNAME, string_key, |