Upload file using curl command line in dokuwiki

2019-09-15 04:23发布

问题:

I am trying to find a way to do this. So far I have been able to access pages thanks to the cookie parameter:

 curl -v --cookie cookies.txt --cookie-jar cookies.txt --user-agent Mozilla/4.0 --data "u=login&p=passwd" http://wiki/doku.php?id=start&do=login

and then

 curl --cookie  cookies.txt  http://wiki/doku.php?id=info

To upload a file I am supposed to get the form parameter on the php page. I don't exactly know what I am looking for :

curl --form "file=@z.xml" --cookie cookies.txt "http://wiki/doku.php?id=start&tab_files=upload&do=media"

回答1:

I made it work differently. I have created a upload.php file (source)

<?php

$uploaddir = '/var/www/html/dokuwiki/upload/';
$uploadfile = $uploaddir . basename($_FILES['upload']['name']);

echo "<p>";

if (move_uploaded_file($_FILES['upload']['tmp_name'], $uploadfile)) {
  echo "File is valid, and was successfully uploaded.\n";
} else {
   echo "Upload failed";
}

echo "</p>";
echo '<pre>';
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";

?>

And the curl command (source)

curl --form upload=@file --form press=OK http://wiki/upload/upload.php

To finish I have allowed a few hosts in httpd.conf

<Directory "/var/www/html/dokuwiki/upload">
Order allow,deny
Allow from 192.168.1