I have got such a weird problem whenever I try to read the fullpath from the file uploader control whether Asp or Html, no difference , got same results for both, the full path starts with C:\\fakepath, I don't know how this path came out,
I tried System.Io.Path.GetFullPath(fileUpload.PostedFile,Filename); I got c:\\windows\\system32....
I put the uploader and other controls in aspx page [Content Holder] linked to a master page which uses Ajax & Rad controls..
What makes it weirder that it worked for me on separate application, no ajax, no master, just nothing other than the uploader + submit button controls.
FireFox and chrome can not get the full client file path because of the security. To my own opinion, I think it is no necessary to get the the client path to server.
If you want to do this, you can consider to use javascript:
<script language=javascript>
function GetFilePath()
{
var uploadFileControl = document.getElementById('<%=FileUpload1.ClientID%>');
var filePath = filePath.value;
}
</script>
Thanks for the reply, I tried it, but even still showing me C:\fakepath.. damn it
even when we deployed the site, trying to enable "include windows local path" from the IE8, but on the server, it didn't work at all... still googling.. what an issue!
Why don't you try and read the path through javascript code
You said you just wanted the path then try it onclick of the upload control or on onblur and try to get the value i think as File upload is rendered as a input box on client side you should be able to get the path which you can store in a hidden field
I tried the javascript code, and i saved the value into Hidden field to be used by code behind, but same Fakepath as well, it is really weird, I am just trying to know why that feature in IE8, it is supposed to be a better version, I don't know.. Gonna keep
googling...!
I think if you use IE browser, using FileUpload1.FileName will only give you the file name. Using FileUpload1.PostedFile.FileName you can get the full path of file and it's no necessary to use System.Io.Path.GetFullPath again.
Response.Write(FileUpload1.FileName); //file name
Response.Write("</br >");
Response.Write(this.FileUpload1.PostedFile.FileName); // full path of file(only in IE)
hananjameel
0 Points
7 Posts
fakepath issue when I use FileUpload
Nov 30, 2010 09:57 AM|LINK
Hello All,
I have got such a weird problem whenever I try to read the fullpath from the file uploader control whether Asp or Html, no difference , got same results for both, the full path starts with C:\\fakepath, I don't know how this path came out,
I tried System.Io.Path.GetFullPath(fileUpload.PostedFile,Filename); I got c:\\windows\\system32....
I put the uploader and other controls in aspx page [Content Holder] linked to a master page which uses Ajax & Rad controls..
What makes it weirder that it worked for me on separate application, no ajax, no master, just nothing other than the uploader + submit button controls.
Any Idea of what I am going through ...!
Hanan
dasari_uday104
Member
318 Points
74 Posts
Re: fakepath issue when I use FileUpload
Dec 01, 2010 03:58 AM|LINK
Hi,
Use this to get the pathe of the folder to move file to that folder
String path = HttpContext.Current.Request.PhysicalApplicationPath + "foldername//";
save file as
FileUpload1.PostedFile.SaveAs(path+"uploaed file name");
Thanks,
Uday Kiran.D
hananjameel
0 Points
7 Posts
Re: fakepath issue when I use FileUpload
Dec 01, 2010 05:58 AM|LINK
Thanks for the reply, i do appreciate it, but I got from the line of code shown below the path of the application,
I don't wanna save the file, all I want is to read the file and save into XMLDocument and send it to the DB, that is why
I need the Full path of the file which is selected by the User through the File Uploader.
HttpContext.Current.Request.PhysicalApplicationPath.ToString();
Anyways, I read so many blogs about this problem, and all confirmed that it is not a code-related problem, it is all about the IE browser, and they
recommended the following solution:
http://www.google.com/support/forum/p/gmail/thread?tid=576ded691a02adfd&hl=en
For me it worked, but what a solution, how we can expect the end user to do so, we should give him/her a HINT, this will help me a little bit
because I am working on an Internal website used by OUR firm, Hope we can find out something else..!
Thanks anyways,
Zizhuoye Che...
All-Star
21927 Points
1915 Posts
Microsoft
Re: fakepath issue when I use FileUpload
Dec 03, 2010 05:06 AM|LINK
Hi,
FireFox and chrome can not get the full client file path because of the security. To my own opinion, I think it is no necessary to get the the client path to server.
If you want to do this, you can consider to use javascript:
<script language=javascript> function GetFilePath() { var uploadFileControl = document.getElementById('<%=FileUpload1.ClientID%>'); var filePath = filePath.value; } </script>Hope this can help you.
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework
hananjameel
0 Points
7 Posts
Re: fakepath issue when I use FileUpload
Dec 07, 2010 09:28 AM|LINK
Thanks for the reply, I tried it, but even still showing me C:\fakepath.. damn it
even when we deployed the site, trying to enable "include windows local path" from the IE8, but on the server, it didn't work at all... still googling.. what an issue!
aren
Member
41 Points
12 Posts
Re: fakepath issue when I use FileUpload
Dec 07, 2010 10:24 AM|LINK
Hi,
You can make use of System.IO.FileInfo class which you can use to resolve ur issue
fn.FullName will give you physical address of a provided file.
Hope that will help you
kratos_Vimal
Contributor
3744 Points
960 Posts
Re: fakepath issue when I use FileUpload
Dec 07, 2010 10:37 AM|LINK
Why don't you try and read the path through javascript code
You said you just wanted the path then try it onclick of the upload control or on onblur and try to get the value i think as File upload is rendered as a input box on client side you should be able to get the path which you can store in a hidden field
Vimal
hananjameel
0 Points
7 Posts
Re: fakepath issue when I use FileUpload
Dec 07, 2010 01:57 PM|LINK
Thanks Aren for your reply, I tried your code, but it didn't work; I got that path
c:\windows\system32\inetsrv\Test.de-DE.resx
where file is picked from:
C:\Documents and Settings\hjameel\Desktop\Test.de-DE.resx
Thanks anyways !
hananjameel
0 Points
7 Posts
Re: fakepath issue when I use FileUpload
Dec 07, 2010 01:59 PM|LINK
Thanks for your reply kratos_Vimal,
I tried the javascript code, and i saved the value into Hidden field to be used by code behind, but same Fakepath as well, it is really weird, I am just trying to know why that feature in IE8, it is supposed to be a better version, I don't know.. Gonna keep googling...!
Thanks anyways !
Zizhuoye Che...
All-Star
21927 Points
1915 Posts
Microsoft
Re: fakepath issue when I use FileUpload
Dec 08, 2010 07:53 AM|LINK
Hi again,
I think if you use IE browser, using FileUpload1.FileName will only give you the file name. Using FileUpload1.PostedFile.FileName you can get the full path of file and it's no necessary to use System.Io.Path.GetFullPath again.
Response.Write(FileUpload1.FileName); //file name Response.Write("</br >"); Response.Write(this.FileUpload1.PostedFile.FileName); // full path of file(only in IE)Or you can have a look at this article:
http://weblogs.asp.net/ashicmahtab/archive/2009/05/20/fileupload-control-doesn-t-give-full-path-help.aspx
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework