HTML
<input type="file" id="fileInput" />
TypeScript:
ngOnInit(): void {
document.getElementById('fileInput')?.addEventListener(
'change', (event) => {
const input = event.target as HTMLInputElement;
if (input.files && input.files[0]) {
const file = input.files[0];
const fileReader = new FileReader();
fileReader.onload = async () => {
const arrayBuffer = fileReader.result as ArrayBuffer;
const uint8Array = new Uint8Array(arrayBuffer);
console.log(uint8Array);
};
fileReader.readAsArrayBuffer(file);
}
});
}
Nessun commento:
Posta un commento