Search code examples
reactjstypescriptvisual-studio-codeimage-uploadingpass-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 in typescript?


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.


Solution

  • 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