0

I need to fetch only file name right at the moment user selects any file from the dialog box (click on "Open" button after selecting file or just double click on the file itself).

Is there any event of the file control available that can be fired to fetch the file name once dialog box is closed

2
  • I don't think there is need to show any code. But simply i am talking about <input type="file" name="fileupload" id="fileupload" value=""> and i want to fetch file name once we select any file from the dialog box. Commented Oct 5, 2012 at 14:05
  • 1
    @neeraj Have you tried listening to the change & propertychange event of the file control ? Commented Oct 5, 2012 at 14:06

1 Answer 1

5

Try this:

<html>
<head>

<script>

function get_filename(obj) {

    var file = obj.value;
    alert(file);

}

</script>

</head>
<body>

<input type="file" name="file" value="" onchange="get_filename(this);" />

</body>
</html>

Live example:
http://simplestudio.rs/yard/filename/filename.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.