Skip to content

Instantly share code, notes, and snippets.

@kjunichi
Last active October 12, 2016 20:31
Show Gist options
  • Save kjunichi/e53e26b170633f68b022 to your computer and use it in GitHub Desktop.
Save kjunichi/e53e26b170633f68b022 to your computer and use it in GitHub Desktop.
curlコマンドでファイルをアップロードするには

はじめに

Dockerのコンテナ内で作ったファイルを急にホストに持っていきたくなった時

curl

curl -F hoge=@/path/to/file http://ホストのIPアドレス:ポート番号/path

以下のようなフォームをlocalhostの3000番ポートで動かしたとします。

<form method="post" enctype="multipart/form-data" action="/upload">
<input type="file" name="thumbnail">
<input type="submit">
</form>

このようなHTMLの場合

curl -F thumbnail=@/path/to/file http://localhost:3000/upload

Link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment