以多部分形式在fileupload中添加带有curl的值

以多部分形式在fileupload中添加带有curl的值,curl,file-upload,console,Curl,File Upload,Console,我的目标 我尝试通过以太网自动更改嵌入式设备上的某些文件。为此,我创建了一个批处理文件,在我的计算机上使用它来发送文件上传的帖子 我的问题 遗憾的是,我需要在多部分表单的“文件部分”中包含一些特殊值。(name=uploadfile&filename=index.htm)我知道如何向多部分表单添加更多值,但我不知道如何向封装在多部分表单中的“文件部分”添加值 我的问题 如何使用curl向多部分表单的“文件部分”添加更多信息/值?甚至可以使用批处理文件中的curl吗 请求应该是这样的: POST

我的目标

我尝试通过以太网自动更改嵌入式设备上的某些文件。为此,我创建了一个批处理文件,在我的计算机上使用它来发送文件上传的帖子

我的问题

遗憾的是,我需要在多部分表单的“文件部分”中包含一些特殊值。(name=uploadfile&filename=index.htm)我知道如何向多部分表单添加更多值,但我不知道如何向封装在多部分表单中的“文件部分”添加值

我的问题

如何使用curl向多部分表单的“文件部分”添加更多信息/值?甚至可以使用批处理文件中的curl吗

请求应该是这样的:

POST /cgi-bin/fs_fileupload.cgi HTTP/1.1
Host: 192.168.1.72
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Referer: http://192.168.1.72/files.html
Connection: keep-alive
Content-Length: 21930
Content-Type: multipart/form-data; boundary=---------------------------86458141819368430751619760852

-----------------------------86458141819368430751619760852
Content-Disposition: form-data; name="uploadfile"; filename="index.htm"
Content-Type: text/html

<html>
...
...
</html>

-----------------------------86458141819368430751619760852
Content-Disposition: form-data; name="path"

/
-----------------------------86458141819368430751619760852
Content-Disposition: form-data; name="submit"

upload
-----------------------------86458141819368430751619760852--
更多输出

== Info:   Trying 192.168.1.72...
== Info: TCP_NODELAY set
== Info: Connected to 192.168.1.72 (192.168.1.72) port 80 (#0)
=> Send header, 211 bytes (0xd3)
0000: POST /cgi-bin/fs_fileupload.cgi HTTP/1.1
002a: Host: 192.168.1.72
003e: User-Agent: curl/7.54.0
0057: Accept: */*
0064: Content-Length: 21875
007b: Content-Type: multipart/form-data; boundary=--------------------
00bb: ----07d21aa34b954425
00d1:
=> Send data, 153 bytes (0x99)
0000: --------------------------07d21aa34b954425
002c: Content-Disposition: form-data; name="file"; filename="index.htm
006c: "
006f: Content-Type: application/octet-stream
0097:
=> Send data, 16384 bytes (0x4000)
0000: <html>
...
...
13de: </html>
=> Send data, 243 bytes (0xf3)
0000:
0002: --------------------------07d21aa34b954425
002e: Content-Disposition: form-data; name="path"
005b:
005d: /
0060: --------------------------07d21aa34b954425    
008c: Content-Disposition: form-data; name="submit"
00bb:
00bd: upload
00c5: --------------------------07d21aa34b954425--
== Info: Recv failure: Connection was reset
== Info: stopped the pause stream!
== Info: Closing connection 0
curl: (56) Recv failure: Connection was reset
==信息:正在尝试192.168.1.72。。。
==信息:TCP\U节点延迟设置
==信息:连接到192.168.1.72(192.168.1.72)端口80(#0)
=>发送头,211字节(0xd3)
0000:POST/cgi-bin/fs_fileupload.cgi HTTP/1.1
002a:主机:192.168.1.72
003e:用户代理:curl/7.54.0
0057:接受:*/*
0064:内容长度:21875
007b:内容类型:多部分/表单数据;边界=--------------------
00bb:--07d21aa34b954425
00d1:
=>发送数据,153字节(0x99)
0000:------------------------------------07d21aa34b954425
002c:内容配置:表单数据;name=“file”;filename=“index.htm
006c:“
006f:内容类型:应用程序/八位字节流
0097:
=>发送数据,16384字节(0x4000)
0000: 
...
...
13de:
=>发送数据,243字节(0xf3)
0000:
0002:------------------------------------07d21aa34b954425
002e:内容处置:表单数据;name=“路径”
005b:
005d:/
0060:------------------------------------07d21aa34b954425
008c:内容配置:表单数据;name=“提交”
00bb:
00bd:上传
00c5:----------------------------07d21aa34b954425--
==信息:Recv故障:连接已重置
==信息:已停止暂停流!
==信息:正在关闭连接0
curl:(56)Recv故障:连接已重置

这不管用。Curl告诉我,它无法识别我输入的值。它在嵌入式端不起作用。由于缺少值,连接被重置

好吧,我找到了一个简单的解决办法。我不知道为什么我一开始没有那样做

curl-X POST-H“Expect:”-F“uploadfile=@path/index.htm;filename=index.htm;”-F path=/-F submit=upload

通过这种上传,多部分表单数据看起来和预期的一样

=> Send data, 159 bytes (0x9f)
0000: --------------------------5621ade8c7849eac
002c: Content-Disposition: form-data; name="uploadfile"; filename="ind
006c: ex.htm"
0075: Content-Type: application/octet-stream
009d:
=> Send data, 16384 bytes (0x4000)
0000: <html>
=>发送数据,159字节(0x9f)
0000:------------------------------------5621ade8c7849eac
002c:内容配置:表单数据;name=“uploadfile”;filename=“ind
006c:ex.htm“
0075:内容类型:应用程序/八位字节流
009d:
=>发送数据,16384字节(0x4000)
0000: 
== Info:   Trying 192.168.1.72...
== Info: TCP_NODELAY set
== Info: Connected to 192.168.1.72 (192.168.1.72) port 80 (#0)
=> Send header, 211 bytes (0xd3)
0000: POST /cgi-bin/fs_fileupload.cgi HTTP/1.1
002a: Host: 192.168.1.72
003e: User-Agent: curl/7.54.0
0057: Accept: */*
0064: Content-Length: 21875
007b: Content-Type: multipart/form-data; boundary=--------------------
00bb: ----07d21aa34b954425
00d1:
=> Send data, 153 bytes (0x99)
0000: --------------------------07d21aa34b954425
002c: Content-Disposition: form-data; name="file"; filename="index.htm
006c: "
006f: Content-Type: application/octet-stream
0097:
=> Send data, 16384 bytes (0x4000)
0000: <html>
...
...
13de: </html>
=> Send data, 243 bytes (0xf3)
0000:
0002: --------------------------07d21aa34b954425
002e: Content-Disposition: form-data; name="path"
005b:
005d: /
0060: --------------------------07d21aa34b954425    
008c: Content-Disposition: form-data; name="submit"
00bb:
00bd: upload
00c5: --------------------------07d21aa34b954425--
== Info: Recv failure: Connection was reset
== Info: stopped the pause stream!
== Info: Closing connection 0
curl: (56) Recv failure: Connection was reset
=> Send data, 159 bytes (0x9f)
0000: --------------------------5621ade8c7849eac
002c: Content-Disposition: form-data; name="uploadfile"; filename="ind
006c: ex.htm"
0075: Content-Type: application/octet-stream
009d:
=> Send data, 16384 bytes (0x4000)
0000: <html>