Click here to Skip to main content
15,909,466 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to get the complete file path of the selected file in obout file upload control?
without saving that file in any other folder, like fileUpload1.SaveAs(Server.MapPath("Files/"+filename));

able to get file name but not file path.
Posted
Updated 22-Mar-13 1:26am
v2
Comments
ZurdoDev 22-Mar-13 7:25am    
What do you need it for? It's uploaded to the server when your code gets it and the path is irrelevant. In fact, some browsers, FireFox and Chrome, will report it at a fake path. It is a security issue for your code to see the structure of a client's hard drive.
Geethika075 22-Mar-13 7:52am    
I want to change image for logo through application by providing screen.

C#
System.IO.Path.GetFullPath(FileUpload1.PostedFile.FileName);
   Path.GetFileName(FileUpload1.PostedFile.FileName);
   System.IO.Path.GetDirectoryName(FileUpload1.PostedFile.FileName).ToString();
   Convert.ToString(System.IO.Directory.GetParent(FileUpload1.PostedFile.FileName));
 
Share this answer
 
Comments
Geethika075 22-Mar-13 8:06am    
This is working for asp upload control, but not for obout upload control.For obout control am getting like "C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\181-hammer@2x.png"
write this line on ur code for full path . . use it Server.MapPath

FileUpload1.SaveAs(Server.MapPath("download/" + FileUpload1.FileName));

and u want to dir info so write this . .

DirectoryInfo dirinfo = new DirectoryInfo(Server.MapPath("IMG/"));


Or:---
If you want the file location in client machine

You can use

string fileLoacation=FileUpload1.PostedFile.FileName;
 
Share this answer
 
imageUpload.PostedFiles[0].SaveAs(Server.MapPath("~/CMS_Images/logos.jpg"));

I have just overwritten the existing image(logos) with the uploasded file. It has worked.
 
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