public UploadFile()
{
//File Data
this.filePath = $("#inputFile").val();
var file = $("#inputFile").get(0).files[0];
var reader = new FileReader();
reader.onload = function (evt) {
var fileContent = reader.result;
var x = fileContent.bytes;
}
Your question isn't completely clear, but here's some sample code that may help. This should be valid TypeScript code, which reads a file from input element #inputFile and displays the text from it in a div with id #divMain.
$("#inputFile").on('change', null, (e) => {
var input = <HTMLInputElement>e.target;
var files = input.files;
var f:File = files[0];
var reader = new FileReader();
var name = f.name;
console.log("File name: " + name);
reader.onload = function (e) {
var target: any = e.target;
var data = target.result;
$("#divMain").text(data);
};
reader.readAsText(f);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With