Hello. I'm using version 1.16, and I'm trying to use curl to call the
API to upload files specified in a form by the user. So, the user
submits via a POST the file they want to upload, and the php copies that
file to a temporary spot on the server. I then use curl to tell the API
to upload that file, but it says
<error code="uploaddisabled" info="Uploads are not enabled...
Even though I can totally upload through Special:Upload just fine.
Here's the curl (this is after obtaining an edit token in code that
works fine as a setup for creating new articles):
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookiefile.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookiefile.txt');
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type:
multipart/form-data"));
curl_setopt($ch, CURLOPT_URL,
"http://$server_name/w/api.php?action=upload&token=$edittoken&filename=$
filename&url=http://$server_name/upload_tmp/$filename");
I'm also confused as to how to call it using the 'file' option instead,
as the manual says if takes 'file contents', and the examples has
'file=file_contents_here'. When I try that method with the curl
curl_setopt($ch, CURLOPT_URL,
"http://$server_name/w/api.php?action=upload&token=$edittoken&filename=$
filename&file=file_contents_here");
then I get the error:
<error code="missingparam" info="One of the parameters sessionkey,
file,
url is required"
So, what's 'file contents' supposed to contain? Thanks for the help.
Will Preston
Network Administrator
OLSON KUNDIG ARCHITECTS
206.624.5670
olsonkundigarchitects.com <http://www.olsonkundigarchitects.com/>