分段上传表:是否保证订单? [英] Multipart upload form: Is order guaranteed?

查看:181
本文介绍了分段上传表:是否保证订单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看来,当我使用html表单来创建一个Content-Type:multipart / form-dataPOST请求时,这些字段总是按HTML中列出的顺序显示。在实践中,所有浏览器都这样做吗?



希望知道这一点的主要动机是,我可以对表单数据进行服务器端验证,无需缓存整个 > RAM中的HTTP请求|



我知道CGI,PHP等通常不会做任何事情,直到上传完成。可能是因为RFC 2388第5.5节通过说明未定义顺序来解决这个问题。我工作w /高度定制的thttpd的fork和处理上传w / C代码内置到服务器。所以我不在乎大多数服务器做什么。



我想知道的是,如果我出去在一个肢体和承担一个命令,我会被烧

 < form id =formUpload
target =uploadTarget
method =post
action =/ bin / upload
enctype =multipart / form-data> ;
< input type =hiddenid =inUsername =user/>
< input type =hiddenid =inDestname =dest/>
< input type =fileid =inFilename =file/>
< input type =buttonvalue =Uploadonclick =uploadFile(); />
< iframe id =uploadTargetname =uploadTargetsrc =style =width:0; height:0; border:0px/>
< / form>

'uploadFile()'函数将填充用户& dest字段,然后调用submit()。我想验证用户&在 recv() - 整个HTTP请求主体

解决方案

是:


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


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


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.

解决方案

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

这篇关于分段上传表:是否保证订单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆