IonInput type file

Hello

There is a way to upload an image file with in IonInput as is possible with an input tag?

Type ‘“file”’ is not assignable to type ‘“number” | “time” | “text” | “tel” | “url” | “email” | “search” | “date” | “password” | “week” | “month” | “datetime-local” | undefined’. TS2322

<IonInput className="ingresarFoto" id="inputFile1" type="file" accept="image/*" onChange={ handleChange("foto1")} />

im still searching the same, you found something about it?

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)
}
4 Likes