'I manage to upload the image but on the firebase storage but it says undefined

I cant preview the image inside the store, it says undefined I manage to upload it on images/ folder but the name of the file is undefined instead of the actual name of the image

enter image description here

const uploadFile = () => {



  console.log(selectedImages);
  const storageRef = ref(storage, 'images/' + selectedImages.name);

  const uploadTask = uploadBytesResumable(storageRef, selectedImages, metadata);
  console.log(selectedImages);

  uploadTask.on('state_changed',
    (snapshot) => {

      const progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
      console.log(progress);
      console.log('Upload is ' + progress + '% done');
      switch (snapshot.state) {
        case 'paused':
          console.log('Upload is paused');
          break;
        case 'running':
          console.log('Upload is running');
          break;
        default:
          break;
      }
    },
    (error) => {
      console.log(error);
    },
    () => {
      // Upload completed successfully, now we can get the download URL
      getDownloadURL(uploadTask.snapshot.ref).then((downloadURL) => {
        console.log('File available at', downloadURL);
      });
    }
  );

};


Solution 1:[1]

import {uploadString} from "@firebase/storage";//use this in rather than uploadbytes uploadString(imageRef,imageToPost,'data_url')//use format of your file type it works for me

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Divyanshu Gehlot