Angular – FileReader() dont get any path

I try to pass an Image in an dialog where the User can crop the image via cropperjs and can upload it afterwards but sometimes the FileReader() didnt get any path.

It is strange, sometimes it works but most of the time my variable is empty… i think did is random because i dont find a pattern to get the URL.

This component.ts

  constructor(private route: ActivatedRoute, public dialog: MatDialog,) { }
  @Input() user: any
  @Input() userProfile: any
  @Input() userPosts: any
  imageSource: any = null;

  ngOnInit(): void { {user: any}) => { this.user = data.user;}); {userProfile: any}) => { this.userProfile = data.userProfile;}); {userPosts: any}) => { this.userPosts = data.userPosts;});

  openDialog(src:string): void {
    const dialogRef =, {
      width: '500px',
      minHeight: '350px',
      data: src,

    dialogRef.afterClosed().subscribe(result => {
      if(result) {

  uploadFile($event) {

    if ($ && $[0]) {
      const file = $[0];

      const reader = new FileReader();
      reader.onload = e => this.imageSource = reader.result;


This is my html

 <div class="UserImageDiv">
        <img [src]="userProfile.profileImagePath" class="UserImage">
        <button mat-icon-button matTooltip="Profilbild ändern" class='changeUserImg' (click)="">
        <input hidden type="file" #uploader (change)="uploadFile($event)" />

Can someone please help me?
Is there another way to get the Path of an Image upload?

Source: Angular Questions