From ad643d35ad4a40a03a48b9cb0d03387e033c8935 Mon Sep 17 00:00:00 2001 From: draj1010 <45226595+draj1010@users.noreply.github.com> Date: Tue, 3 Nov 2020 10:21:52 +0530 Subject: [PATCH] Append random string on form id - i was implementing queue functionality. in that in a single file i have more then 10 objects and forms. when i add files in different objects faster then (new Date().getTime()) will create same ids. so it was conflicting my queue function. so i recommend you to use random string function to resolve that case. - see this screenshot https://i.imgur.com/0sTWv8N.png. in that i have already append random string. thank you :) --- js/jquery.uploadfile.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/js/jquery.uploadfile.js b/js/jquery.uploadfile.js index af29383..77a9c94 100755 --- a/js/jquery.uploadfile.js +++ b/js/jquery.uploadfile.js @@ -96,7 +96,7 @@ this.fileCounter = 1; this.selectedFiles = 0; - var formGroup = "ajax-file-upload-" + (new Date().getTime()); + var formGroup = "ajax-file-upload-" + (new Date().getTime()) + random_str_gen(9); this.formGroup = formGroup; this.errorLog = $("
"); //Writing errors this.responses = []; @@ -537,6 +537,16 @@ } } + function random_str_gen(length) { + var result = ''; + var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + var charactersLength = characters.length; + for ( var i = 0; i < length; i++ ) { + result += characters.charAt(Math.floor(Math.random() * charactersLength)); + } + return result; + } + function createCustomInputFile (obj, group, s, uploadLabel) { var fileUploadId = "ajax-upload-id-" + (new Date().getTime());