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
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
Share Improve this question asked Oct 5, 2012 at 13:59 NeerajNeeraj 9,21518 gold badges62 silver badges90 bronze badges 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. – Neeraj Commented Oct 5, 2012 at 14:05
-
1
@neeraj Have you tried listening to the
change
&propertychange
event of the file control ? – HoLyVieR Commented Oct 5, 2012 at 14:06
1 Answer
Reset to default 5Try 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