6

input type="file" stopped working in Android Instagram in-app browser recently. It was working fine earlier. It still works fine in iOS. I also tested it in Facebook in-app browser which also works fine on both Android and iOS.

Here is my simple test codes.

<!DOCTYPE html> 
<html>
<head>
    <title>File Validation</title>
</head>
<body>
    <p>
        <input type="file" id="file" onchange="checkFileSize()" />
    </p>
    <p id="size"></p>
</body>
<script>
    var checkFileSize = function() {
        var input = document.getElementById('file');

        if (input.files.length > 0) {
            for (var i = 0; i < input.files.length; i++) {
                var fsize = input.files[i].size;
                var file = Math.round((fsize / 1024));

                document.getElementById('size').innerHTML = '<b>' + file + '</b> KB';
            }
        }
    }
</script>
</html>

It just prints the file size on selection of a file. I have also uploaded the html to my Amazon S3 for easier testing. Here is the page link - https://virtueplanet.s3.amazonaws.com/testfile/index.html

If you open the link in Instagram in-app browser and select a file from your phone then it always returns the file size as zero (0). I also tried to read the file using Filereader which also fails.

var input = document.getElementById('file');

if (input.files.length > 0) {
    for (var i = 0; i < input.files.length; i++) {
        var reader = new FileReader();

        reader.onload = function(e) {
            alert('Image loaded.');
        }

        reader.onerror = function() {
            alert(reader.error.message);
        }

        reader.readAsDataURL(input.files[i]);
    }
}

It appears to be bug in the recent Instagram App update for Android. Any help will be highly appreciated.

Jumbo
  • 176
  • 6

0 Answers0