Why is filereader not working?
<p>I have a chat app built with socket.io and node.js. I have a function below for reading the file from the input and sending it to the server as a base64 string.</p>

<pre><code>function readURL() {
    if (this.files &amp;&amp; this.files[0]) {
         var FR= new FileReader();
         FR.onload = function(e) {
              $("img").attr("src", e.target.result);
              socket.emit('image', e.target.result);
              console.log(e.target.result);
         };       
         FR.readAsDataURL( this.files[0] );
    } 
};
</code></pre>

<p>My HTML is as follows: </p>

<pre><code>&lt;input id="file" type='file' onchange="readURL()"/&gt;
&lt;img id="img"&gt;
</code></pre>

<p>However, upon uploading a file, nothing happens. No errors are recorded, and nothing is even logged to the console. Why is this so?</p>