Trying to upload images to website by encoding it to Base64. I have this code that works in new Chrome/Mozzilla/IE11. But it doesn't work in Safari 5.1.4 (Windows)
I can see now that FileReader is not available at safari until version 6.0, So any alternatives to this?
This is the code :
<input id="#avatar" type="file" onchange="previewFile()">
<script>
var img;
function previewFile() {
  var file    = document.querySelector('input[type=file]').files[0];
  var reader  = new FileReader();
  reader.addEventListener("load", function () {
    img = reader.result;
    alert(img)
  }, false);
  if (file) {
    reader.readAsDataURL(file)
  }
}
<...>
</script>