Closed djxhero closed 8 years ago
Which version of the plugin are you using?
Hi LPology, I'm using Simple Ajax Uploader v2.4 . I fixed this problem by removing a statment in _initUpload function:
_initUpload: function( fileObj ) {
...
//remove following statement ,because same file name param add in _uploadXhr function twice
//params[this._opts.name] = fileObj.name;
headers['X-Requested-With'] = 'XMLHttpRequest';
headers['X-File-Name'] = fileObj.name;
...
because this param actually is added in _uploadXhr function:
_uploadXhr:function( fileObj, url, params, headers, sizeBox, progBar, progBox, pctBox, abortBtn, removeAbort ) {
"use strict";
...
if ( opts.multipart === true ) {
var formData = new FormData();
for ( var prop in params ) {
if ( params.hasOwnProperty( prop ) ) {
formData.append( prop, params[prop] );
}
}
// this is right file name param
formData.append( opts.name, fileObj.file );
this.log( 'Commencing upload using multipart form' );
xhr.send( formData );
}
...
maybe my method not work for non-mulipart situation , hope you can fix that
I met the problem either with the latest version 2.4.0. Setting the name option with 'file' , there will be two 'file' in the form-data.
------WebKitFormBoundaryys9VdMimwU0Aeiux
Content-Disposition: form-data; name="file"
user/image/296/J99BXJv35iIAQlTrqSbmiJOR6L8Zc8Kj_1453565318410.jpg
------WebKitFormBoundaryys9VdMimwU0Aeiux
Content-Disposition: form-data; name="file"; filename="10.jpg"
Content-Type: image/jpeg
@djxhero +1 Remove that line is working for me. @LPology Maybe it is a bug ?
@ablipan @djxhero This is a good catch. Just pushed an update (version 2.5.0) that removes this line.
Thanks for your input.
fileName pass twice when submit as multipart; I don't know whether it is a bug or not
the first name param just only the custom file name param I named it, and the second is custom file name param and real filename ;
and this not work with my server side program,so I remove the first fileName param.
--------------original param pass like :-------------
-----I remove the first file name param , and this work for me-