通过javascript获取文件上传文件的文件名 [英] get the filename of a fileupload in a document through javascript
本文介绍了通过javascript获取文件上传文件的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
var fu1 = document.getElementById(FileUpload1);
如何使用 id FileUpload1获取fileupload控件的文件名
属性,如下所示:
var fu1 = document.getElementById(FileUpload1);
alert(您已选择+ fu1.value);
注意: FileUpload1
是一个ASP.Net服务器端的FileUpload控件。
如果是这样,你应该使用 ClientID
属性,如下所示:
var fu1 = document.getElementById(<%= FileUpload1.ClientID%>);
var fu1 = document.getElementById("FileUpload1");
how can i get the filename of fileupload control with id FileUpload1
解决方案
Try the value
property, like this:
var fu1 = document.getElementById("FileUpload1");
alert("You selected " + fu1.value);
NOTE: It looks like FileUpload1
is an ASP.Net server-side FileUpload control.
If so, you should get its ID using the ClientID
property, like this:
var fu1 = document.getElementById("<%= FileUpload1.ClientID %>");
这篇关于通过javascript获取文件上传文件的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文