Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
hello friends,

In my Application i m using <asp:FileUpload ID="fileupload" runat="server"/>

and on click of this fileupload i want to excess the path of file.

path of my drive like d:/foldername/foldername/...


how i can do this.

Please help.
Posted
Updated 6-Dec-11 23:17pm
v2

Server.MapPath will gives you path of uploaded file.
C#
Server.MapPath(FileUpload1.FileName);
 
Share this answer
 
Comments
Amir Mahfoozi 8-Dec-11 0:34am    
+5
try this code:

C#
<pre><asp:FileUpload ID="FileUpload1" runat="server" /><br />
    <asp:Button ID="Button2" runat="server" Text="Upload" onclick="Button2_Click"/>
    <br />
protected void Button2_Click(object sender, EventArgs e)
   {
       FileUpload1.SaveAs(Server.MapPath("~/Uploads")+FileUpload1.FileName);
   }
 
Share this answer
 
Because of security reasons you cannot get the complete path of your file in Firefox or other browsers, but only in explorer you can get complete path else where it'll not work.

C#
Server.MapPath(FileUpload1.FileName);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900