Generation

botón para abrir un archivo local desde html

html <input type="file" id="fileinput" /> <script> document.getElementById('fileinput').addEventListener('change', readSingleFile, false); function readSingleFile(evt) { var f = evt.target.files[0]; if (f) { var r = new FileReader(); r.onload = function(e) { var contents = e.target.result; alert( "Got the file.n" +"name: " + f.name + "n" +"type: " + f.type + "n" +"size: " + f.size + " bytesn" + "starts with: " + contents.substr(1, contents.indexOf("n")) ); } r.readAsText(f); } else { alert("Failed to load file"); } } </script>

Questions about programming?Chat with your personal AI assistant