Bug #77617 [NEW]: curl_setopt_array Triggers warning when used with CURLFile in CURLOPT_POSTFIELD
| From: | lawrence at dub3solutions dot com | Date: | Wed, 13 Feb 2019 23:53:51 +0000 |
| Subject: | Bug #77617 [NEW]: curl_setopt_array Triggers warning when used with CURLFile in CURLOPT_POSTFIELD | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-219569@lists.php.net to get a copy of this message | ||
From: lawrence at dub3solutions dot com
Operating system: CentOS 7
PHP version: 7.2.15
Package: cURL related
Bug Type: Bug
Bug description:curl_setopt_array Triggers warning when used with CURLFile in CURLOPT_POSTFIELD
Description:
------------
When building an options array, setting one of the CURLOPT_POSTFIELDS
key/values to a CURLFile object will result in the following PHP
Warning:
PHP Warning: curl_setopt_array(): Invalid filename for key
variable_name
When this warning is raised, curl_setopt_array returns true, and
proceeds normally except it skips any files added.
Not sure if this is the proper method, but I was asked to tag @bishop
who was following my issue on stackoverflow.
https://stackoverflow.com/questions/54680799/php-7-2-curlfile-gives-invalid-filename-warning
Test script:
---------------
$curl = curl_init();
$curlOpts = array(
CURLOPT_POST => 1,
CURLOPT_URL => $postUrl,
CURLOPT_TIMEOUT => 20,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_USERPWD => 'apikey'
);
$postFields = array('var1' => 'value');
$postFields['variable_name'] = curl_file_create($filePath);
$curlOpts[CURLOPT_POSTFIELDS] = $postFields;
curl_setopt_array($curl, $curlOpts);
$curl_response = curl_exec($curl);
$info = curl_getinfo($curl);
curl_close($curl);
Expected result:
----------------
I would expect the file to get added to the curl options.
Actual result:
--------------
The file is ignored and a warning is added to the http logs
PHP Warning: curl_setopt_array(): Invalid filename for key
variable_name
--
Edit bug report at https://bugs.php.net/bug.php?id=77617&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77617&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77617&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77617&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77617&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77617&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77617&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77617&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77617&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77617&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77617&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77617&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77617&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77617&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77617&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77617&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77617&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77617&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77617&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77617&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77617&r=mysqlcfg