分段上传表单:订单有保证吗?

发布于 2024-12-05 04:26:25 字数 1041 浏览 1 评论 0原文

看来,当我使用 html 表单发出“Content-Type: multipart/form-data”POST 请求时,字段始终按照 HTML 中列出的顺序显示。实际上,所有浏览器都这样做吗?

想知道这一点的主要动机是这样我就可以对表单数据进行服务器端验证,而不需要将整个 HTTP 请求缓存在 RAM 中 |首先是磁盘。

我知道 CGI、PHP 等通常在上传完成之前不会执行任何操作。可能是因为 RFC 2388 第 5.5 节通过说未定义顺序来解决此问题。我正在使用高度定制的 thttpd 分支,并使用服务器中内置的 C 代码处理上传。所以我不在乎大多数服务器做什么。

我想知道的是,如果我冒着风险承担一项命令,我会因为这种假设而受伤吗?

以此形式为例:

  <form id="formUpload"
        target = "uploadTarget"
        method = "post"
        action = "/bin/upload"
        enctype= "multipart/form-data" >
    <input type="hidden" id="inUser" name="user" />
    <input type="hidden" id="inDest" name="dest"/>
    <input type="file" id="inFile" name="file" />
    <input type="button" value="Upload" onclick="uploadFile();" />
    <iframe id="uploadTarget" name="uploadTarget" src="" style="width:0;height:0;border:0px"/>
  </form>

'uploadFile()' 函数将填写用户名和密码。调用submit()之前的dest字段。我想验证用户和dest 服务器端也是如此,在 recv() 处理整个 HTTP 请求正文之前。

It appears that when I use an html form to make a "Content-Type: multipart/form-data" POST request, the fields always appear in the order in which they are listed in the HTML. In practice, do all browsers do this?

The primary motivation for wanting to know this is so I can do server-side validation of form data w/o being required to cache the entire HTTP request in RAM | disk first.

I know CGI, PHP, etc typically won't do anything 'til the upload completes. Probably because RFC 2388 section 5.5 addresses this issue by saying the order is not defined. I'm working w/ a highly customized fork of thttpd and handling the upload w/ C code built right into the server. So I don't care what most servers do.

What I want to know, is if I go out on a limb and assume an order, will I get burned by that assumption?

Take this form for example:

  <form id="formUpload"
        target = "uploadTarget"
        method = "post"
        action = "/bin/upload"
        enctype= "multipart/form-data" >
    <input type="hidden" id="inUser" name="user" />
    <input type="hidden" id="inDest" name="dest"/>
    <input type="file" id="inFile" name="file" />
    <input type="button" value="Upload" onclick="uploadFile();" />
    <iframe id="uploadTarget" name="uploadTarget" src="" style="width:0;height:0;border:0px"/>
  </form>

The 'uploadFile()' function will fill in the user & dest fields before invoking submit(). I would like to validate user & dest server side as well, before recv()-ing the entire HTTP request body.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三生一梦 2024-12-12 04:26:25

是的:

这些部件按照相应控件在文档流中出现的顺序发送到处理代理。任何数据中不应出现部分边界;如何完成此操作超出了本规范的范围。

http://www.w3.org/TR/html4 /interact/forms.html#h-17.13.4

Yes:

The parts are sent to the processing agent in the same order the corresponding controls appear in the document stream. Part boundaries should not occur in any of the data; how this is done lies outside the scope of this specification.

http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文