メインコンテンツまでスキップ

4.2. 各パートのContent-Dispositionヘッダフィールド

4.2. Content-Disposition Header Field for Each Part

🇬🇧 英文原文

Each part MUST contain a Content-Disposition header field [RFC2183] where the disposition type is "form-data". The Content-Disposition header field MUST also contain an additional parameter of "name"; the value of the "name" parameter is the original field name from the form (possibly encoded; see Section 5.1). For example, a part might contain a header field such as the following, with the body of the part containing the form data of the "user" field:

Content-Disposition: form-data; name="user"

For form data that represents the content of a file, a name for the file SHOULD be supplied as well, by using a "filename" parameter of the Content-Disposition header field. The file name isn't mandatory for cases where the file name isn't available or is meaningless or private; this might result, for example, when selection or drag-and-drop is used or when the form data content is streamed directly from a device.

If a "filename" parameter is supplied, the requirements of Section 2.3 of [RFC2183] for the "receiving MUA" (i.e., the receiving Mail User Agent) apply to receivers of multipart/form-data as well: do not use the file name blindly, check and possibly change to match local file system conventions if applicable, and do not use directory path information that may be present.

In most multipart types, the MIME header fields in each part are restricted to US-ASCII; for compatibility with those systems, file names normally visible to users MAY be encoded using the percent-encoding method in Section 2, following how a "file:" URI [URI-SCHEME] might be encoded.

NOTE: The encoding method described in [RFC5987], which would add a "filename*" parameter to the Content-Disposition header field, MUST NOT be used.

Some commonly deployed systems use multipart/form-data with file names directly encoded including octets outside the US-ASCII range. The encoding used for the file names is typically UTF-8, although HTML forms will use the charset associated with the form.


🇯🇵 日本語訳

各パートには、配置タイプが「form-data」であるContent-Dispositionヘッダフィールド[RFC2183]を含める必要がある(MUST)。Content-Dispositionヘッダフィールドには、「name」という追加のパラメータも含める必要がある(MUST)。「name」パラメータの値は、フォームからの元のフィールド名である(エンコードされている可能性がある。セクション5.1を参照)。たとえば、パートには次のようなヘッダフィールドが含まれる可能性があり、パートの本体には「user」フィールドのフォームデータが含まれる:

Content-Disposition: form-data; name="user"

ファイルの内容を表すフォームデータの場合、Content-Dispositionヘッダフィールドの「filename」パラメータを使用して、ファイルの名前も提供すべきである(SHOULD)。ファイル名が利用できない、無意味、またはプライベートである場合、ファイル名は必須ではない。これは、たとえば、選択またはドラッグアンドドロップが使用される場合、またはフォームデータコンテンツがデバイスから直接ストリーミングされる場合に発生する可能性がある。

「filename」パラメータが提供されている場合、「受信MUA」(すなわち、受信メールユーザーエージェント)に対する[RFC2183]のセクション2.3の要件は、multipart/form-dataの受信者にも適用される: ファイル名を盲目的に使用せず、該当する場合はローカルファイルシステムの規則に一致するように確認し、場合によっては変更し、存在する可能性のあるディレクトリパス情報を使用しないこと。

ほとんどのマルチパートタイプでは、各パートのMIMEヘッダフィールドはUS-ASCIIに制限されている。これらのシステムとの互換性のため、通常ユーザーに表示されるファイル名は、「file:」URI[URI-SCHEME]がエンコードされる方法に従って、セクション2のパーセントエンコーディング方法を使用してエンコードしてもよい(MAY)。

注記: Content-Dispositionヘッダフィールドに「filename*」パラメータを追加する[RFC5987]で説明されているエンコーディング方法は、使用してはならない(MUST NOT)。

一般的に展開されているシステムの中には、US-ASCII範囲外のオクテットを含む直接エンコードされたファイル名でmultipart/form-dataを使用するものがある。ファイル名に使用されるエンコーディングは通常UTF-8であるが、HTMLフォームはフォームに関連付けられた文字セットを使用する。