0

I want the selected file to be removed when I click the button. Using the below example

this.state{ file:null}

 <input type="file" onChange={this.handleFile}/>
 
<button type="submit" onClick={this.handleSubmit}>Continue</>


handleSubmit (){
      this.setState({file: null})
      }
Talha Tayyab
  • 8,111
  • 25
  • 27
  • 44
Gabriel
  • 35
  • 1
  • 8
  • Does this answer your question? [How can I clear an HTML file input with JavaScript?](https://stackoverflow.com/questions/1703228/how-can-i-clear-an-html-file-input-with-javascript) – Emiel Zuurbier Jun 22 '22 at 17:27

1 Answers1

0

It is basically impossible to change the text in an input/type=file field. The reason for this is that it would open up a huge security hole.

Try using an <input type=reset> button?

ControlAltDel
  • 33,923
  • 10
  • 53
  • 80