1

when ever i choose a file for example image2.jpg i want that no file choosen text to change into the filename

<input type="file"onChange={this.onChange} value={this.state.allValues.BloodReport} />

enter image description here

full code i have put in codesand box

vivek kn
  • 107
  • 1
  • 18
  • 45
  • You cannot set value programmatically to input with type file => https://stackoverflow.com/questions/1696877/how-to-set-a-value-to-a-file-input-in-html#:~:text=The%20only%20way%20to%20set,file%20from%20the%20client's%20computer. – Amila Senadheera Jan 04 '22 at 07:16

2 Answers2

2

Use it without value property. name will be showed automaically.

<input type="file"onChange={this.onChange} />
1

Remove value from <input type="file" /> then try !

<input
  style={styles.cutumbuttons}
  type="file"
  style={styles.cutumbuttons}
  name="ultraSound"
  // accept="application/pdf"
  onChange={this.onChange}
//value={this.state.allValues.BloodReport}
/>
Mayur Vaghasiya
  • 1,383
  • 2
  • 12
  • 24