A simple example:
<input type="file" (change)="onFileSelected($event)"/>
Then in the code itself.
onFileSelected($event) {
if ($event.target.files.length == 0)
return 0;
let file = $event.target.files[0];
let fileReader = new FileReader();
fileReader.onload = () => {
console.log(fileReader.result);
}
fileReader.readAsDataURL(file);
}
Tags
Angular