HttpPostedFile.FileName - Different from IE

后端 未结 4 1366
南旧
南旧 2020-12-09 02:44

When I upload a file to a site using the ASP:File control the FileName property is different in IE and Firefox. In Firefox, it just provides the name of the file, but IE pr

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-09 03:33

    A simple workaround for this tested in IE and Chrome

    new FileInfo(myHttpPostedFileBase.FileName).Name
    

    This will ensure you always get just the file name even if the path is included.

提交回复
热议问题