I'm getting a typerror with Filereader() in Angular 17

Discussão em 'Angular' iniciado por Zayno lane, Novembro 14, 2024.

  1. Zayno lane

    Zayno lane Guest

    all I'm getting this typerror, and I can't figure it out. I've searched Google, but I can't seem to find an answer.


    TypeError: Argument 1 ('blob') to FileReader.readAsDataURL must be an instance of Blob
    ​

    here is my component method:

    onFilePick(event: Event) {
    const file = (event.target as HTMLInputElement).files;
    //console.log(file);
    // console.log(this.form);
    this.form.patchValue({ Image: file });
    this.form.get('image')?.updateValueAndValidity();
    const reader: any = new FileReader();
    reader.onload = () => {
    this.imagePreview = reader.result;
    };
    return reader.readAsDataURL(file);
    }

    Continue reading...

Compartilhe esta Página