Created
August 18, 2013 05:07
-
-
Save ymxmore/6259987 to your computer and use it in GitHub Desktop.
FileオブジェクトからdataURIを取得
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 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