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 这个复选框什么作用?
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决