Upload file using curl command line in dokuwiki

若如初见. 提交于 2019-12-25 05:00:16

问题


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



来源:https://stackoverflow.com/questions/15142344/upload-file-using-curl-command-line-in-dokuwiki

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!