# IonInput type file

**URL:** <https://forum.ionicframework.com/t/ioninput-type-file/205203>\
**Category:** Ionic React\
**Created:** [February 21, 2021, 5:51am UTC](https://forum.ionicframework.com/t/ioninput-type-file/205203 "2021-02-21T05:51:06Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![aaronksaunders](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/aaronksaunders/32/13729_2.png) [@aaronksaunders](https://forum.ionicframework.com/u/aaronksaunders)\
**Post date:** [April 27, 2021, 7:17pm UTC](https://forum.ionicframework.com/t/ioninput-type-file/205203/3 "2021-04-27T19:17:41Z")

</div>

I just use an hidden input field and an ionic button

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

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

```

code

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

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

```

---

_[View the full topic](https://forum.ionicframework.com/t/ioninput-type-file/205203)._
