Problems with posted filename on IE
When working with posted files make sure to use Path.GetFileName for extrancting the posted file name.
HttpPostedFileBase postedFile = httpContext.Request.Files[0];
string postedFileName = postedFile.FileName;
/* FF CHROME WORKS FINE */
OUTPUTS : someFile.jpg
/* IE OUTPUTS C:\user\folder\folder\someFile.jpg
Correct way:
HttpPostedFileBase postedFile = httpContext.Request.Files[0];
string postedFileName = Path.GetFileName(postedFile.FileName);
Written by Ion D. Filho
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#.net
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#