note 78328 deleted from ref.curl by felipe
| From: | felipe@php.net | Date: | Sun, 30 Mar 2008 19:02:10 +0000 |
| Subject: | note 78328 deleted from ref.curl by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-137765@lists.php.net to get a copy of this message | ||
Note Submitter: jfkallen at hotmail dot com
----
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.