I am creating a small html5 app that will allow users to change color properties of some elements. I want to give the user the option to save their changes and then upload them on later occasion (without registration). For this, I added a button that produces a text file of their properties, I want to add a button that will allow them to upload the file, I created a file picker dialog,
<label> <input class="button" type="file" name="input-name" style="display:none;" onchange="read(event)"/> <span id="input-file" >Select File</span> </label> But I can't figure how do I open this file in javascript and process its content. I know this should be similar to this
function read(evt){ var file = document.getElementById("input-file"); //checking for file reader if (window.File && window.FileReader && window.FileList && window.Blob){ var r = new FileReader(); r.readAsText(file); } else{ alert("Browser not supported"); } } But this doesn't work because file above is not the path to the file but the object. How do I get the path to the file? Is there a better way to do this?