====== cURL 上傳 multipart/form-data 檔案語法 ====== 假設要上傳的網頁 form 如以下所示:

Send this file:
這表示要上傳要有 id 與 uploadfile (檔案) cURL 的語法就可以寫成如下: curl curl -F uploadfile=@/tmp/ttt.zip "http://upload.server.com/api/api.php?id=fromServerQueue/pid,2008-10-29%2018:10:32" **主要的重點在於** - 選擇檔案使用 **-F xxxx=@filepath** 來表示, **xxxx** 表示上傳的變數, **filepath** 就是要上傳檔案的路徑 - url 內的參數內容出現空白要改用 %20 替代, 所以 2008-10-29 18:10:32 改用 \\ 2008-10-29%2018:10:32 呈現 ===== 參考網頁 ===== * [[http://www.lslnet.com/linux/f/docs1/i24/big5212166.htm|轉:Scripting HTTP Requests Using Curl]] {{tag>curl}}