[Shell command] curl でファイル送信する

作成日: 2025年03月01日

curl コマンドの -F オプションを使用すると、ファイルを送信することができます。下記の例では、/tmp/dummy.txt というファイルを送信しています。

curl -F "somefile=@/tmp/dummy.txt" https://example.com/upload

このコマンドは、somefile というフィールド名で /tmp/dummy.txt ファイルを送信します。サーバー側で somefile フィールドを受け取ることで、ファイルを処理することができます。

Shell command