2014-01-18 66 views
0

我想從特定的文件目錄張貼到服務器捲曲的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 

當使用網站上的表格發送正常。這裏是表格:

<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> 

這怎麼解決?

回答

2

使用這樣的:

curl -v -include --form "[email protected]/home/pi/Documents/2014-01-18-09:11:25.jpeg" http://hostdomain.me/file/upload 
         ^^^^^^^^^^
+0

我得到無法解析HTTP主體:: {[錯誤:請求中止]狀態:4 400}響應的服務器和網關504在超時終端捲曲。有任何想法嗎? –

+0

你可以在firefox上安裝firebug;然後轉到Net標籤並將文件上傳到您的網站;你可以看到你的請求;右鍵點擊請求並選擇_copy作爲cURL_;在此之後,如果你看到成功的上傳文件,你可以將捲曲粘貼到bash上並運行它。 –