file from mobile using FileReader but looks like it doesn't even call console.log (the input tag is input type file and hidden).... maybe I missed something?
<script type="text/javascript">
window.onload = function() {
const file = "file:///data/data/com.termux/files/home/test.txt";
const input = document.querySelector('input');
input.files[0] = file;
input.addEventListener('load', (event) => {
let fr = new FileReader();
var f = event.target.files[0];
fr.addEventListener("change", function() {
console.log("text: " + fr.result);
document.querySelector("useragent").innerText = fr.result;
});
fr.readAsText(f);
});
}
</script>
!var
Please stop using var. It was deprecated in 2015. Use const or let instead
The browser is sandboxed. It does not have access to the user's files. The user must explicitly select a file using an <input type="file">, otherwise your JS cannot access it
Обсуждают сегодня