Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 将带有图像文件的POST表单卷曲到表单_Node.js_Bash_Curl_Terminal_Sails.js - Fatal编程技术网

Node.js 将带有图像文件的POST表单卷曲到表单

Node.js 将带有图像文件的POST表单卷曲到表单,node.js,bash,curl,terminal,sails.js,Node.js,Bash,Curl,Terminal,Sails.js,我正在尝试将JPEG图像从特定的文件目录发布到服务器。这是我键入的内容: curl -v -include --form filedata='/home/pi/Documents/2014-01-18-09:11:25.jpeg' http://hostdomain.me/file/upload 执行此命令后,终端返回以下信息: * Couldn't find host rdnvpfwnwk.localtunnel.me in the .netrc file; using defaults *

我正在尝试将JPEG图像从特定的文件目录发布到服务器。这是我键入的内容:

curl -v -include --form filedata='/home/pi/Documents/2014-01-18-09:11:25.jpeg' http://hostdomain.me/file/upload
执行此命令后,终端返回以下信息:

* Couldn't find host rdnvpfwnwk.localtunnel.me in the .netrc file; using defaults
* About to connect() to rdnvpfwnwk.localtunnel.me port 80 (#0)
*   Trying 192.34.58.73...
* connected
* Connected to rdnvpfwnwk.localtunnel.me (192.34.58.73) port 80 (#0)
> POST /file/upload HTTP/1.1
> User-Agent: curl/7.26.0
> Host: rdnvpfwnwk.localtunnel.me
> Accept: */*
> Content-Length: 186
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=----------------------------affc91df7bc3
>
* additional stuff not fine transfer.c:1037: 0 0
* HTTP 1.1 or later with persistent connection, pipelining supported
< HTTP/1.1 100 Continue
HTTP/1.1 100 Continue

* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* HTTP 1.1 or later with persistent connection, pipelining supported
< HTTP/1.1 500 Internal Server Error
HTTP/1.1 500 Internal Server Error
< Server: nginx
Server: nginx
< Date: Sat, 18 Jan 2014 11:44:39 GMT
Date: Sat, 18 Jan 2014 11:44:39 GMT
< Content-Type: text/plain
Content-Type: text/plain
< Content-Length: 9245
Content-Length: 9245
< Connection: keep-alive
Connection: keep-alive
< X-Powered-By: Sails <sailsjs.org>
X-Powered-By: Sails <sailsjs.org>
* Added cookie sails.sid="s%3AAucWnGhDSzZSGB_tBgSXJoU2.DMQ4FuVVRRGLFGheMgr4CvIFUICCiP9Gqd5GIjRevA8" for domain rdnvpfwnwk.localtunnel.me, path /, expire 0
< Set-Cookie: sails.sid=s%3AAucWnGhDSzZSGB_tBgSXJoU2.DMQ4FuVVRRGLFGheMgr4CvIFUICCiP9Gqd5GIjRevA8; Path=/; HttpOnly
Set-Cookie: sails.sid=s%3AAucWnGhDSzZSGB_tBgSXJoU2.DMQ4FuVVRRGLFGheMgr4CvIFUICCiP9Gqd5GIjRevA8; Path=/; HttpOnly

* HTTP error before end of send, stop sending
<
TypeError: Cannot read property 'name' of undefined
*在.netrc文件中找不到主机rdnvpfwnk.localtunnel.me;使用默认值
*即将连接()到rdnpfwnwk.localtunnel.me端口80(#0)
*正在尝试192.34.58.73。。。
*连接的
*已连接到rdnvpfwnk.localtunnel.me(192.34.58.73)端口80(#0)
>POST/file/upload HTTP/1.1
>用户代理:curl/7.26.0
>主机:rdnpfwnwk.localtunnel.me
>接受:*/*
>内容长度:186
>预期:100人继续
>内容类型:多部分/表单数据;边界=------------------------------------affc91df7bc3
>
*附加材料未精细转移。c:1037:0
*HTTP 1.1或更高版本,支持持久连接和流水线
在网站上使用表单时,表单会正确发送。表格如下:

<form id="uploadForm"
enctype="multipart/form-data"
action="/file/upload"
method="post">
<input type="file" id="userPhotoInput" name="userPhoto" />
<input type="submit" value="Submit">
</form>

如何修复此问题?

使用此选项:

curl -v -include --form "userPhoto=@/home/pi/Documents/2014-01-18-09:11:25.jpeg" http://hostdomain.me/file/upload
                         ^^^^^^^^^ ^

我无法解析服务器上的HTTP正文::{[Error:Request aborted]status:4400}和504网关超时以响应终端中的curl。有什么想法吗?你可以在firefox上安装firebug;然后转到网络选项卡并将文件上载到您的站点;你可以看到你的请求;右键单击请求并选择复制为卷曲;在此之后,如果您看到上传文件成功,您可以将curl粘贴到bash上并运行它。。