IonInput type file

I just use an hidden input field and an ionic button

<input
  type="file"
  id="file-upload"
  style={{ display: "none" }}
  onChange={setImage}
/>

<IonButton onClick={openFileDialog}>
  <IonIcon slot="icon-only" icon={camera}></IonIcon>
</IonButton>

code

const openFileDialog = () => {
   (document as any).getElementById("file-upload").click();
};

const setImage = (_event: any) => {
  let f = _event.target.files![0];
  console.log(f)
}
5 Likes