I have created a application in ORACLE APEX
Where I have file browser , textbox and submit. when I select the file its first line should be read and displayed in textbox on click of submit button
<!DOCTYPE html>
<html>
<body>
<p>Choose file:</p>
<input type="file" id="myFile" name="filename">
<input type="submit">
<br><br>
<label for="fname">First line from csv file :</label>
<input type="text" id="fname" name="fname">
</body>
</html>
My Js code
function confirmFileSubmit(){
var input = document.getElementById('fileUpload'); // get the input
var file = input.files[0]; // assuming single file, no multiple
var reader = new FileReader();
reader.onload = function(e) {
var text = reader.result; // the entire file
var firstLine = text.split('\n').shift(); // first line
console.log(firstLine); // use the console for debugging
}
reader.readAsText(file, 'UTF-8'); // or whatever encoding you're using
// UTF-8 is default, so this argument
}