Hi,

I want to use the new Upload-API. I have seen that I cannot upload per URL
to Commons because I (my bot) haven't the
upload_by_url right. So I change my tool to the file argument:

$new_file = <Name of the target file>;
$url = <URL of the source file>;
$desc = <Description>;
$filename = <Name of the source file>;
$this->server = 'commons.wikimedia.org';

$connect = fsockopen ($this->server, 80, $err_num, $err_str, 10);
                
$token = $this->get_token();
                
$file = file_get_contents( $url );
$query = "POST
/w/api.php?format=php&action=upload&filename=".urlencode($new_file)."&token=
".urlencode($token)."&file=".urlencode($filename)."&comment=".urlencode($des
c)." HTTP/1.1
Host: ".$this->server."
Cookie: ".$cookies."
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7)
Gecko/20041107 Firefox/1.0
Content-Type: multipart/form-data
Content-Length: ".strlen($file)."
Content-Disposition: form-data; name=\"".$filename."\";
filename=\"".$filename."\"

".$file."
\r\n\r\n";
fputs ($connect,$query);

But now I get this error: array(1) { ["error"]=>  array(2) { ["code"]=>
string(12) "missingparam" ["info"]=>  string(69) "One of the parameters
sessionkey, file, url, enablechunks is required" } }

What is wrong?

Viele Grüße
Jan


_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to