// Retrieve the dropped files from the event object using e.originalEvent.dataTransfer.files var files = e.originalEvent.dataTransfer.files; // Loop through the files array $.each(files, function(index, file) { // Initialise a new file reader var reader = new FileReader(); // What to do once the reader.onload = function(event) { // Split the file contents after the first comma (removing the base64 prefix) var base64 = event.target.result.split(',')[1]; var fileName = file.name; var fileType = file.type; var fileSize = file.size; // Run the uploadToNoteAttachment function, passing the base64 content, the file name and the file type uploadToNoteAttachment(base64,fileName,fileType); }; // Read the file reader.readAsDataURL(file); });