Skip to content

Commit c5219e8

Browse files
committed
Do not append file into FormData if already has !
Sometimes people may want to minimize the file size and will do some compress then set the new compressed file into the form. Therefore when data already contains new file, do not append the original one.
1 parent dc8968e commit c5219e8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

SimpleAjaxUploader.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,14 +1756,22 @@ ss.XhrUpload = {
17561756

17571757
if ( opts.multipart === true ) {
17581758
var formData = new FormData();
1759-
1759+
1760+
var hasFile = false;
1761+
17601762
for ( var prop in params ) {
17611763
if ( params.hasOwnProperty( prop ) ) {
1764+
if (prop === opts.name) {
1765+
hasFile = true;
1766+
}
17621767
formData.append( prop, params[prop] );
17631768
}
17641769
}
1765-
1766-
formData.append( opts.name, fileObj.file );
1770+
1771+
if (!hasFile) {
1772+
formData.append( opts.name, fileObj.file );
1773+
}
1774+
17671775
this.log( 'Commencing upload using multipart form' );
17681776
xhr.send( formData );
17691777

0 commit comments

Comments
 (0)