Typeerror: Cannot read Property 'files' of Undefined

Asked

Viewed 847 times

0

I have following code snippet for upload Storage firebse I am using typescript.

uploadPhoto(photo) {
//Get File
this.file = photo.files[0]; // Erro nessa linha

this.metadata = {
  'contentType': this.file.type
};

//Create a storage ref
this.storageRef = firebase.storage().ref().child('images/');

// Upload file
this.storageRef.put(this.file, this.metadata);

}

he make following mistake:

TypeError: Cannot read property 'files' of undefined

1 answer

0


That kind of mistake TypeError: Cannot read property 'files' of undefined usually occurs because the value is lost, either by not passing the parameter or because it was not obtained or set. If you go through the code from the beginning, you will realize that at some point this value has been lost.

  • am passing: uploadImage() { this.userProvider.uploadPhoto(this.Photofield); }

  • Check the this.photoField. He must be as Undefined.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.