Created
          April 5, 2012 15:56 
        
      - 
      
- 
        Save melvynhills/2312114 to your computer and use it in GitHub Desktop. 
    Load local image files into the DOM
  
        
  
    
      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
    
  
  
    
  | // http://html5doctor.com/drag-and-drop-to-server/ | |
| var acceptedTypes = { | |
| 'image/png': true, | |
| 'image/jpeg': true, | |
| 'image/gif': true | |
| }; | |
| if (acceptedTypes[file.type] === true) { | |
| var reader = new FileReader(); | |
| reader.onload = function (event) { | |
| var image = new Image(); | |
| image.src = event.target.result; | |
| image.width = 100; // a fake resize | |
| document.body.appendChild(image); | |
| }; | |
| reader.readAsDataURL(file); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment