jquery-based AJAXS use Formdata to upload files note the two parameter settings
ProcessData set to False
Set ProcessData to False so that jquery does not handle formdata, and if ProcessData is not set to false,jquery the Formdata is converted to a string.
ContentType set to False
Example of HTTP sending Multipart/form-data request message
post/api/feed/http/1.1accept-encoding:gzipcontent-length:225873Content-type:multipart/form-data; boundary= OCQXMF6-JXTXOMDHMOG5W5EY9MGRSTBPHost:www.myhost.comConnection: Keep-alive--ocqxmf6-jxtxomdhmog5w5ey9mgrstbpcontent-disposition:form-data; Name= "LNG" content-type:text/plain; Charset=utf-8content-transfer-encoding:8bit116.361545--ocqxmf6-jxtxomdhmog5w5ey9mgrstbpcontent-disposition: Form-data; Name= "lat" content-type:text/plain; Charset=utf-8content-transfer-encoding:8bit39.979006--ocqxmf6-jxtxomdhmog5w5ey9mgrstbpcontent-disposition: Form-data; Name= "Images"; Filename= "/storage/wbavrx.jpg" content-type:application/octet-streamcontent-transfer-encoding: Binary here is the binary data of the picture--ocqxmf6-jxtxomdhmog5w5ey9mgrstbp--
Note Content-Type: multipart/form-data; boundary=OCqxMF6-JxtxoMDHmoG5W5eY9MGRsTBp that the parameter boundary is the bounds identifier between the request parameters.
If the jquery request is set to ContentType, then the Formdata content-type is overwritten, causing the server to be unable to find boundary when separating the parameters and the contents of the file, reporting an no multipart boundary was found error
By default, jquery sets ContentType to application/x-www-form-urlencoded. To jquery without setting contenttype, you need to set ContentType to false.
var formData = new FormData ($ ("#uploadform") [0]), $.ajax ({ url:actionurl, type: ' POST ', data:formdata, Async:false, cache:false, contenttype:false, processdata:false, ...});
Ajax uses Formdata to upload files asynchronously, error The request was rejected because no multipart boundary was found