一键发送多个文件时,javascript formdata 是否保持插入顺序?
Does the javascript formdata keep its insertion order when sending multiple files in one key?
我正在尝试通过 FormData 对象发送多个文件。我没有问题,因为我知道我可以将每个文件附加到同一个密钥并以这种方式发送。但是,我想知道插入顺序是否得到保留和保证。换句话说,我可以按照我在前端的相同顺序在后端检索文件吗?我查看了 MDN 文档,但在这里找不到它。
虽然有点密集,https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#submit-body lists the algorithms that must be followed for the different post methods, so in this case that would be https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart/form-data-encoding-algorithm,其中指出:
The order of parts must be the same as the order of fields in entry list. Multiple entries with the same name must be treated as distinct fields.
所以答案似乎是"yes, if the user agent correctly implements the serialization of the FormData object"。
我正在尝试通过 FormData 对象发送多个文件。我没有问题,因为我知道我可以将每个文件附加到同一个密钥并以这种方式发送。但是,我想知道插入顺序是否得到保留和保证。换句话说,我可以按照我在前端的相同顺序在后端检索文件吗?我查看了 MDN 文档,但在这里找不到它。
虽然有点密集,https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#submit-body lists the algorithms that must be followed for the different post methods, so in this case that would be https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart/form-data-encoding-algorithm,其中指出:
The order of parts must be the same as the order of fields in entry list. Multiple entries with the same name must be treated as distinct fields.
所以答案似乎是"yes, if the user agent correctly implements the serialization of the FormData object"。