Do you know this guy System.Web.HttpPostedFile? yeah, he is my best friend when it comes to uploading file in ASP.NET. However you should know that he acted bit strange with browse in used.
Let say file1 is an instance of HttpPostedFile and if we ask him file1.FileName
Firefox return :Anyway quick fix would be add a small detection on the file1.FileName
"Hello My Friend.doc"
Nice , isn't it?
IE return :
"C:\Document & Setting ....\user_name\desktop\Hello My Friend.doc"
WWOWO WHAT?! it slap me so hard to make me laugh out loud :))
Not Nice !
int lastDirSeparatorChar = file1.FileName.LastIndexOf(Path.DirectorySeparatorChar);Lesson learn - test dev. site with IE as much as I hate "IE"
if (lastDirSeparatorChar > 0)
{
filename = file1.FileName.Substring(lastDirSeparatorChar + 1);
}
else
{
filename = file1.FileName
}