#49921 [Asn->Csd]: Curl post upload functions changed
| From: | iliaa@php.net | Date: | Mon, 26 Oct 2009 12:57:08 +0000 |
| Subject: | #49921 [Asn->Csd]: Curl post upload functions changed | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-143955@lists.php.net to get a copy of this message | ||
ID: 49921
Updated by: iliaa@php.net
Reported By: jon at feburman dot co dot uk
-Status: Assigned
+Status: Closed
Bug Type: cURL related
Operating System: *
PHP Version: 5.*, 6 (2009-10-21)
Assigned To: iliaa
New Comment:
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2009-10-26 12:57:01] svn@php.net
Automatic comment from SVN on behalf of iliaa
Revision: http://svn.php.net/viewvc/?view=revision&revision=289934
Log: Fixed bug #49921 (Curl post upload functions changed).
------------------------------------------------------------------------
[2009-10-21 13:35:00] jani@php.net
See also bug #49943
------------------------------------------------------------------------
[2009-10-20 10:14:38] jani@php.net
Ilia, see also bug #48962 (and especially the last comment there :)
------------------------------------------------------------------------
[2009-10-19 17:44:23] jon at feburman dot co dot uk
I have had to go back to 5.2.10 (which works correctly) as this bug
broke our live site, so I cannot test this - and you will need
to fill in some values for the variables at the bottom.
But, off the top of my head, something like:
<?PHP
function upload($dir, $file, $userpass, $url) {
$ch = curl_init();
if($ch) {
$data = array('dir' => $dir, 'filedata0' => "@$file");
if( !curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ) return false;
if( !curl_setopt($ch, CURLOPT_URL, $url)) return false;
if( !curl_setopt($ch, CURLOPT_USERPWD, $userpass)) return false;
if( !curl_setopt($ch, CURLOPT_POST, 1)) return false;
if( !curl_setopt($ch, CURLOPT_POSTFIELDS, $data)) return false;
if( !curl_exec($ch) ) return false;
curl_close($ch);
return true;
}
else return false;
}
$dir = "uploads"; //Not needed - but in our case this was a required
post
$file = "/local/path/to/a/file"; //Local path to a file
$userpass = "auser:apasswd"; //Remote login details
$url = "remote/upload/url"; //A remote upload page
upload($dir, $file, $userpass, $url);
?>
On the remote system see what the upload file is called. If it makes
any difference, our remote system was a Solaris 9 box.
------------------------------------------------------------------------
[2009-10-19 14:31:48] jani@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/49921
--
Edit this bug report at http://bugs.php.net/?id=49921&edit=1