A few questions to consider when uploading files using HTML form forms

Source: Internet
Author: User
Tags html form keep alive

file upload is often required in the application system, the general practice is to use the HTML <form> and <input type= "file", or use third-party files to upload components, such as SWFUpload and uploadify. We all know that if you submit data to the server, typically using a POST request, the request data is placed in the request body in key1=value1&key2=value2 form. Such a message, the server is very easy to parse. If it is uploading files, through the HttpWatch capture tool, we can find: the contents of the file is also placed in the POST request body.

We know that when you submit a form, you can upload the file and submit the parameter values at the same time. This raises the question: the request parameter value and the file content are in the POST request body, the server must be able to identify the message, which is the parameter value, which is the file content? How does the HTTP protocol solve this problem? You can view the rfc1867 document:form-based file Upload in HTML. There are 2 blog posts below.

Http://www.cnblogs.com/chy710/archive/2010/02/22/1671007.html

http://blog.csdn.net/xiaojianpitt/article/details/6856536

the implementation details are well explained. If the details of the message, we can use httpclient and other open source components, self-build request messages, to achieve file upload. We know that the HTTP request is stateless and the connection hold time is not too long. So how to achieve efficient and robust file upload, need to consider a lot of details, need to understand the HTTP protocol some of the head such as contenttype,keep alive mechanism.

After implementing the basic upload function, it is generally necessary to consider how to upload large files. How do I implement a breakpoint upload? How do I implement asynchronous uploads? Upload Multiple files together? Wait a minute.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.