Remember once ajax file upload

A new requirement to submit the page.

When the page is submitted, using, first upload the file and then upload form

It should be returned in the form of file storage address, you need to upload. and so. After uploading files are stored in the return address.

One mistake here:

To the input of the type put inside the storage address file, the browser will complain InvalidStateError: An attempt was made to use an object that is not, or is n

Later, using a type of input for the text hidden. Files saved to the address there.

And then remember where noted when a file upload

When you upload a file started:

var file = $(this)[0].files[0];

Direct data: file

Later changed

var fd = new FormData();
        fd.append( "file", file);

 

Guess you like

Origin www.cnblogs.com/sunshine99/p/11308223.html