fileupload控件的问题,怎么获得他的浏览的路径啊???
单击fileupload控件的浏览,选择文件,我想这样,
单击一个button按钮,把在文本框中显示的字符串路径显示在lable中,
怎么样获取fileupload的上传路径啊?????急等
[解决办法]
FileUpload.PostedFile.FileName是客户端的文件全名
[解决办法]
试试这样的事例代码
<script runat="server" language="c#">
public string getlbID()
{
return this.lb.ClientID;
}
public void Page_Load(object o,eventargs e)
{
fl.attributes.add("onchange","document.getElementById('"+getlbID()+"').value=this.value;");
}
</script>
<asp:label id="lb" runat="server"></asp:lable>
<asp:fileupload id="fl" runat="server"></asp:fileupload>
[解决办法]
<asp:Label ID="MyLabelID" runat="server"></asp:Label>
<asp:fileupload id="fl" runat="server" onchange="document.getElementById('MyLabelID').innerText=this.value"> </asp:fileupload>
[解决办法]
页面代码:
<body>
<form id="form1" runat="server">
<div>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></div>
</form>
</body>
后台代码:
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text= FileUpload1.PostedFile.FileName.ToString();
}