Created
February 14, 2017 03:15
-
-
Save brijeshb42/90b2865ffdd7e244ee0ab789922fe6df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var element = document.querySelector('.droppable'); | |
var droppedFiles = []; | |
function callback(files) { | |
for(var i=0; i<files.length; i++) { | |
droppedFiles.push(files[i]); | |
} | |
} | |
makeDroppable(element, callback); | |
var uploadBtn = document.querySelector('.upload-btn'); | |
uploadBtn.addEventListener('click', function() { | |
for(var i=0; i<droppedFiles.length; i++) { | |
var formData = new FormData(); | |
formData.append("files", droppedFiles[i]); | |
$.ajax({ | |
url: '/server_upload_url', | |
method: 'post', | |
data: formData, | |
processData: false, | |
contentType: false, | |
success: function(response) { | |
alert('File ' + droppedFiles[i].name + ' uploaded successfully.'); | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment