om. om. - 1 year ago 73
Javascript Question

How to get uploaded file name

I want to access file name from

<input type="file">


I console
element[0].files
and get this result:

enter image description here

I want to use image name which highlighted in screenshot.

Answer Source

You can access the FileList using .files property. Get the File object at index 0 of FileList using bracket notation. Get the "name" property of the File object using .name

element[0].files[0].name
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download