Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当用户从对话框中选择任何文件时,我只需要获取文件名(选择文件后单击“打开”按钮或双击文件本身)。
一旦对话框关闭,是否有任何可用的文件控件事件可以触发以获取文件名
尝试这个:
<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>
现场示例: http ://simplestudio.rs/yard/filename/filename.html