how to browse file and get file path in asp.net

Posted by Gow.Net under ASP.NET on 9/20/2012 | Points: 10 | Views : 28963 | Status : [Member] | Replies : 7
how to browse file and get file path in asp.net?

gowthaman8870226416


Responses

Posted by: Hariinakoti on: 9/20/2012 [Member] Starter | Points: 25

Up
0
Down
see this link
http://www.c-sharpcorner.com/UploadFile/mahesh/BrowseorOpenaFile12012005010624AM/BrowseorOpenaFile.aspx

Thanks & Regards
Hari

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/20/2012 [Member] Starter | Points: 25

Up
0
Down
If u satisfied with my answer please click on Mark As Answer

Thanks & Regards
Hari

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Divyaselvarathinam on: 9/21/2012 [Member] Starter | Points: 25

Up
0
Down
You can get path from your File upload control as simple as this..
-----File Upload Control---
<asp:FileUpload ID="FileUpload1" name="FileUpload1" runat="server" />

-----Get path in codebehind------
System.IO.Path.GetFullPath(FileUpload1.FileName)

Divya

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pgayath on: 9/21/2012 [Member] Starter | Points: 25

Up
0
Down
Gowthaman:
You can use FileUpload control in ASP .NET to select a file.
<asp:FileUpload ID="FileUpload1" name="FileUpload1" runat="server" /> 

and get the filename by getting FileUpload1.FileName as
string strFileName = FileUpload1.FileName;



Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kianurieves on: 9/22/2012 [Member] Starter | Points: 25

Up
0
Down
Use these steps
1. create a new project of ASP.NET
2. now, just simply add a Web form page in to your application
3. Now Add a FileUpload control and Button control from the ToolBox to the WebForm.aspx Page.
4. Now simply just add the below code snippet in to WebForm1.aspx.cs file.
http://www.dapfor.com/en/net-suite/net-grid/features/performance


Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ddheeru88 on: 11/6/2012 [Member] Starter | Points: 25

Up
0
Down
This code not work because this gives a common library path of file where file not exits

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Seng2hs on: 11/8/2012 [Member] Starter | Points: 25

Up
0
Down
<script type="text/javascript">
function OnSubmitFile(myForm)
{
var fileUpload = document.getElementById('<% = fUpload.ClientID %>');
myForm.action = myForm.action + "?FilePath=" + fileUpload.value;
return true;
}
</script>


<form id="Form1" method="post" runat="server" onsubmit="return OnSubmitFile(this);">
<asp:FileUpload id="fUpload" runat="server" />
</form>

FireFox send file without full file path, so to retrieve file path you do it on client side via javascript function

you can also create hidden form field and send to server if you dint wish to send via querystring

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response