HMTL/Javascript not allowing same file input twice

Hey all I have a little html code

    <input type="file" id="fileInput" multiple onchange="readSingleFile(this)">  <p align="center">         <button class='btn btn-primary' onclick="javascript:callValidatorService();">VALIDATE</button>         <button class='btn btn-primary' id="fileSelectButton">BROWSE</button>         <button class='btn btn-primary' onclick="javascript:loadSample();">SAMPLE</button>         <button class='btn btn-primary' onclick="javascript:clearText();">CLEAR</button>       </p>        <script>         function click(el)          {             // Simulate click on the hidden file element.             var evt = document.createEvent('Event');             evt.initEvent('click', true, true);             el.dispatchEvent(evt);         }          document.querySelector('#fileSelectButton').addEventListener('click', function(e)          {             //When we click the browse button, instead click the hidden file element.             var fileInput = document.querySelector('#fileInput');             fileInput.click();          }, false);       </script> 

This allows for a pop-up menu to appear to allow a user to choose a file. However it doesn't allow for multiple inputs of the same file name even if the contents of the file have changed.

Here is my javascript code that goes along with it

function readSingleFile(fileElement)  {      //This is how users submit a file using the browse button.     var f = fileElement.files[0];      if (f)     {         var r = new FileReader();         r.onload = function(e)          {             var contents = e.target.result;             document.getElementById("inputText").value = contents;             callValidatorService();         }         r.readAsText(f);      }      else      {          alert("Failed to load file");     }     fileElement.files[0]=null;     r=null;     contents=null;     f=null;  } 

I thought on change only cared about the contents of the file not the file name?

Thank you

Replay

Category: javascript Time: 2016-07-28 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.226 (s). 12 q(s)