Button to change the actionJS icon to download a file

I want to know how can I open a directory to download a file using IconButton?

<IconButton 
  iconClassName="fa fa-plus-square" 
  onClick={(e) => e.stopPropagation()} 
  type='file'
/>

using the code below, shows the icon button and another button for the download file

<IconButton iconClassName="fa fa-plus-square" onClick={(e) => e.stopPropagation()}>
    <input type="file type='file'>
</IconButton>
+4
source share
2 answers

Few things:

  • You do not need type='file'an IconButton, just an input

  • IconButton does not expect its children to be anything other than SVGIcon, so I recommend that you use a regular button

  • I would not call stopPropagation in this case

  • You have a typo in your input support type. You have one type="file type='file'. It should be easytype="file"

So, all together:

<FlatButton label="Choose file" labelPosition="before">
  <input type="file" style={styles.exampleImageInput} />
</FlatButton>

, , , , - <input> FlatButton .

+5

IconButton, .

<IconButton onClick={() => this.fileUpload.click()}>
   <FontIcon className="material-icons" >
       add_a_photo
   </FontIcon>
  </IconButton>
<input type="file" ref={(fileUpload) => {
                    this.fileUpload = fileUpload;
                  }}
  style={{ visibility: 'hidden'}} onChange={this.groupImgUpload} />
0

All Articles