admin管理员组文章数量:1391998
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
本文标签: htmlHow to get filename of file control on file selection event using javascriptStack Overflow
版权声明:本文标题:html - How to get filename of file control on file selection event using javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744636214a2616837.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论