Search code examples
javascripthtmliosmobile-safariios8

FileReader not working on iOS 8


I can't get FileReader to work in iOS 8. The following demo illustrates this (jsFiddle link for iOS - http://jsfiddle.net/gys6rubg/1/):

var file = document.getElementById('file-input');
file.addEventListener('change', function(event) {
    var file = this.files[0];
    
    if(!file) {
        alert('No file');
        return;
    }
    
    var reader = new FileReader();
    var timeout = setTimeout(function() {
         alert('FileReader not functioning');   
    }, 500);
    reader.onload = function(event) {
        clearTimeout(timeout);
        alert('Base64 length - ' + event.target.result.length);
    };    
    
    reader.readAsDataURL(file);
});
<form>
    <input id="file-input" type="file" />
</form>

This console.log's the length of the Base64 string in most browsers, but on iOS 8 Safari it console.log's 'FileReader not functioning'.

Is there any way around this, or anything I'm doing wrong?


Solution

  • it's a bug

    should be fixed in the next release