Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This plugin is open source under the MIT License. It was developed in conjuncti
FileReaderJS.setupInput(document.getElementById('file-input'), opts);
FileReaderJS.setupDrop(document.getElementById('dropzone'), opts);
FileReaderJS.setupClipboard(document.body, opts);
FileReaderJS.setupBlob(blob, opts);

## If you have jQuery:
$("#file-input, #dropzone").fileReaderJS(opts);
Expand Down
25 changes: 24 additions & 1 deletion filereader.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ See http://github.com/bgrins/filereader.js for documentation.
var FileReaderJS = window.FileReaderJS = {
enabled: false,
setupInput: setupInput,
setupBlob: setupBlob,
setupDrop: setupDrop,
setupClipboard: setupClipboard,
setSync: function (value) {
Expand Down Expand Up @@ -151,7 +152,30 @@ See http://github.com/bgrins/filereader.js for documentation.
processFileList(e, e.dataTransfer.files, instanceOptions);
}
}
// setupFile: bind the 'change' event to an input[type=file]
function setupBlob(blob, opts) {

if (!FileReaderJS.enabled) {
return;
}

if(blob.constructor !== Array && blob.constructor !== Function){
if(blob.name === undefined){
blob.name = "blob";
}
blob = [blob];
}else{

if(blob[0].name === undefined){
blob[0].name = "blob";
}
}

var instanceOptions = extend(extend({}, FileReaderJS.opts), opts);

processFileList(null, blob, instanceOptions);

}
// setupDrop: bind the 'drop' event for a DOM element
function setupDrop(dropbox, opts) {

Expand Down Expand Up @@ -255,7 +279,6 @@ See http://github.com/bgrins/filereader.js for documentation.

// processFileList: read the files with FileReader, send off custom events.
function processFileList(e, files, opts) {

var filesLeft = files.length;
var group = {
groupID: getGroupID(),
Expand Down