Skip to content

Commit

Permalink
bulk uploader (sort of) for slack emoji
Browse files Browse the repository at this point in the history
really just allows you to drag-and-drop a bunch of images into the
text input of the form, and uploads each of them in turn with name
determined by the file name (stripping one file extension)
  • Loading branch information
Matt Hughes committed Mar 18, 2017
1 parent 3150abf commit cab99d5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions upload-emoji.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
$('form').on('drop', function(e) {
e.preventDefault();
e.stopPropagation();
var files = e.originalEvent.dataTransfer.files;
for(var i = 0; i < files.length; i++) {
var file = files[i];
var ajaxData = new FormData($('form').get(0));
ajaxData.append('img', file);
var fileName = file.name,
name = fileName.substr(0, fileName.lastIndexOf('.')) || fileName;
ajaxData.append('name', name);
$.ajax({
url: 'https://wayfair.slack.com/customize/emoji',
type: 'POST',
data: ajaxData,
cache: false,
contentType: false,
processData: false
});
}
});

0 comments on commit cab99d5

Please sign in to comment.