duanjing1276 2014-10-06 17:53
浏览 98
已采纳

使用cURL POST到基本表单

I thought this would be simple but I can't figure it out. I have a form with this structure:

<form name="input" action="DOTHINGS" method="POST">

<textarea rows="10" cols="30" name="rules"></textarea>

<textarea rows="10" cols="30" name="facts"></textarea>

<br><input type="submit" value="Submit">

So I want to post to the rules and facts text areas and submit. I have tried the following:

curl -F "rules=@/directory/file.txt" -F "facts=@/directory/file.txt" http://localhost:1112/
curl -X POST -d "rules=junktext" http://localhost:1112/
curl --data "rules=junkdata&facts=junkdata" http://localhost:1112/

No matter what I try I get The requested resource could not be found as a response.

I first thought my localhost:1112 was not accessible so I tried variations of that and did a basic curl localhost:1112 which returned the content of the site so it seems it's able to access that URL. However I just can't get anything to POST. Is there something wrong with my syntax or with the form itself?

  • 写回答

3条回答 默认 最新

  • doulu1968 2014-10-06 19:24
    关注

    Since my comment was the answer:

    The action attribute of an HTML form usually names a (relative) URL. http://www.w3.org/TR/html401/interact/forms.html#edef-FORM

    In this case, you need to curl the URL of the form handler:

    curl -d "..." http://localhost:1112/DOTHINGS
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题