Skip to content

Instantly share code, notes, and snippets.

@ymxmore
Created August 18, 2013 05:07
Show Gist options
  • Select an option

  • Save ymxmore/6259987 to your computer and use it in GitHub Desktop.

Select an option

Save ymxmore/6259987 to your computer and use it in GitHub Desktop.
FileオブジェクトからdataURIを取得
var view_file_content = function(data, callback) {
if (!window.FileReader || !data.files || !_.isArray(data.files) || data.files.length <= 0) {
return;
}
var file = data.files[0];
if(file.type.match(/image/)) {
var fr = new FileReader();
fr.onload = function(event) {
callback(event.target.result);
};
fr.readAsDataURL(file);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment