This is a known problem documented on the MSDN – I’m sure I’ve been caught by this before so thought i would blog it!
Firefox and IE7.05XX treat the PostedFile.Filename property differently.
In Firefox, calling FileUpload.PostedFile.Filename will return the name of the file, with no path information.
In IE7, calling FileUpload.PostedFile.Filename will return the full path of the file + the filename.
e.g. if the client file is located at c:\My Documents\Test.xls, Firefox will return ‘Test.xls’, and IE7 will return ‘c:\My Documents\Test.xls’
Related posts:
- The Path ‘/AppName/App_GlobalResources’ maps to a directory outside this application, which is not supported.
- Machine Key Generator
- A complete list of .NET Serializers in 3.5
- ASP.net Roles and Membership installed to local SQL Express 2008 MDF file
- MSDeploy Setup Guide & How to Call Server Side Method Using jQuery/Ajax











#1 by Bhalchandra on September 6, 2010 - 13:01
Thnx buddy. I was struggling with this. Is theres any solution to this problem
#2 by shawson on September 13, 2010 - 10:19
There’s no proper fix, but you can work around it by just checking for slashes in the path that comes back, and clean it up if there is- I do this;
HttpPostedFile f = control.PostedFile;
var cleaned_filename = f.FileName.ToLower();
// ie leaves the path data on the front, so get rid of that!
if (cleaned_filename.Contains(“\\”))
cleaned_filename = cleaned_filename.Substring(cleaned_filename.LastIndexOf(“\\”), cleaned_filename.Length + 1 – cleaned_filename.LastIndexOf(“\\”));