Html5+ajax the key parameter setting of the original zoning block upload file

Source: Internet
Author: User

Processdata:false

This is a parameter of Jquery.ajax. The default value is true, which means that non-string objects are automatically converted to K1=v1&k2=v2 form, such as an array parameter {d:[1,2]}, which becomes d[]=1&d[]=2 after the server.

To set it to false to upload the Arraybuffer object, the server gets the raw byte stream directly from the Request.inputstream.

W3school Explanation:

true " application/x-www-form-urlencoded " false.

Main code: (the following code is called in the Readasarraybuffer completion event onload of the FileReader async method, this points to the current reader)

$.ajax ('/home/file ',                    {                        this. result,                        ' POST ',                        false ,                         function (res) {                            console.log (res);                        },                        function  (err) {                            console.log (err);                        }                    });

The server accepts the file class content:

var stream = Request.inputstream;

Because only HTML5 have FileReader object, so only HTML5 support JS original zoning block upload file.

The previous article uses the WebSocket original zoning block to upload files in a way that only supports HTML5.

Because the http1.1 default Keep-live property, the connection is not re-established each time it is requested. Therefore, the server can not use the WebSocket scenario, but the client is supported by the HTML5 case, the Ajax original zoning block upload.

Html5+ajax the key parameter setting of the original zoning block upload file

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.