note 101231 added to function.curl-setopt
| From: | john dot david dot steele at gmail dot com | Date: | Fri, 03 Dec 2010 21:03:51 +0000 |
| Subject: | note 101231 added to function.curl-setopt | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-174599@lists.php.net to get a copy of this message | ||
A note on the way Curl posts files...
<?php
curl_setopt($ch, CURLOPT_POSTFIELDS, array('file' => '@/path/to/file.ext');
?>
will post the FULL PATH of the file in the filename field:
Content-Disposition: form-data; name="file"; filename="/path/to/file.ext"
Whereas typical browser behavior only sends the filename:
Content-Disposition: form-data; name="file"; filename="file.ext"
Workaround:
<?php
curl_setopt($ch, CURLOPT_POSTFIELDS, array('file' => '@file.ext');
$cwd = getcwd();
chdir('/path/to/');
$receivedData = curl_exec($ch);
chdir($cwd);
?>
----
Server IP: 64.71.164.2
Probable Submitter: 76.98.172.59
----
Manual Page -- http://www.php.net/manual/en/function.curl-setopt.php
Edit -- https://master.php.net/note/edit/101231
Del: integrated -- https://master.php.net/note/delete/101231/integrated
Del: useless -- https://master.php.net/note/delete/101231/useless
Del: bad code -- https://master.php.net/note/delete/101231/bad+code
Del: spam -- https://master.php.net/note/delete/101231/spam
Del: non-english -- https://master.php.net/note/delete/101231/non-english
Del: in docs -- https://master.php.net/note/delete/101231/in+docs
Del: other reasons-- https://master.php.net/note/delete/101231
Reject -- https://master.php.net/note/reject/101231
Search -- https://master.php.net/manage/user-notes.php