Fungsi JavaScript untuk membuka browser file
const browseFiles = () => {
var input = document.createElement('input');
input.type = 'file';
input.click();
}
Cerbrain
const browseFiles = () => {
var input = document.createElement('input');
input.type = 'file';
input.click();
}
window.open("file:///D:/Hello.txt");
function readSingleFile(e) {
var file = e.target.files[0];
if (!file) {
return;
}
var reader = new FileReader();
reader.onload = function(e) {
var contents = e.target.result;
displayContents(contents);
};
reader.readAsText(file);
}
function displayContents(contents) {
var element = document.getElementById('file-content');
element.textContent = contents;
}
document.getElementById('file-input')
.addEventListener('change', readSingleFile, false);