note 78328 added to ref.curl
| From: | jfkallen at hotmail dot com | Date: | Sun, 07 Oct 2007 06:54:09 +0000 |
| Subject: | note 78328 added to ref.curl | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131188@lists.php.net to get a copy of this message | ||
There is a problem with uploading files via CURL. However the issues regarding the @ symbol as well
as references to url_encoding are not the cause of the bug.
The @ symbol is used to send the contents of a file, rather than the string representation of the
file path, to the receiving script. (See Below)
In other posts on this site references are made to CURLOPT_POSTFILEDS being populated with an array
of post variables, however the documentation is clear, this variable is supposed to be a
string,....therefore the following should work.
function Post($vars,$url){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,1);
#curl_setopt($ch,CURLOPT_UPLOAD,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$vars);
curl_exec($ch);
curl_close($ch);
}
$path = "/tmp/test.txt";
$url = "http://www.somesite.com/receive_changes.php";
$vars = "action=submitted&order=receive&file=@$path";
Post($vars,$url);
Unfortunately this does not work.
----
Server IP: 209.41.74.194
Probable Submitter: 67.188.250.232
----
Manual Page -- http://www.php.net/manual/en/ref.curl.php
Edit -- https://master.php.net/note/edit/78328
Del: integrated -- https://master.php.net/note/delete/78328/integrated
Del: useless -- https://master.php.net/note/delete/78328/useless
Del: bad code -- https://master.php.net/note/delete/78328/bad+code
Del: spam -- https://master.php.net/note/delete/78328/spam
Del: non-english -- https://master.php.net/note/delete/78328/non-english
Del: in docs -- https://master.php.net/note/delete/78328/in+docs
Del: other reasons-- https://master.php.net/note/delete/78328
Reject -- https://master.php.net/note/reject/78328
Search -- https://master.php.net/manage/user-notes.php