Warm tip: This article is reproduced from stackoverflow.com, please click
reactjs typescript visual-studio-code image-uploading pass-by-value

How do I get the title of an uploaded image which is to be entered as a value in the image ID column

发布于 2020-03-27 15:42:13

Click to see the upload optionWhen I choose an image file, it gets chosen but I am unable to extract the title of the chosen image. I need to get this title and push it to a table as a part of a column. Is there any way to do the same? Click to see the table fragment

The code sample here.

Questioner
Nidhi Pai
Viewed
82
Ernestas Buta 2020-01-31 16:35

I'm not sure if this is what you're looking for but you can extract the title through onChange like this.

<input
  type="file"
  onChange={x => {
    console.log(x.target.files[0].name);
  }}
/>

here's the sandbox example