event.getFile().getFileName() is returning filename with complete path in JSF2.0 with PrimeFaces 3.5

前端 未结 1 1112
自闭症患者
自闭症患者 2021-01-13 14:37

I am using PrimeFaces v3.5 to upload the files in my windows machine using Firefox browser. event.getFile().getFileName() is returning filename with complete pa

相关标签:
1条回答
  • 2021-01-13 15:13

    Commons IO offers FilenameUtils#getName() for the exact purpose.

    String filename = FilenameUtils.getName(event.getFile().getFileName());
    

    See also:

    • Commons FileUpload FAQ on the subject
    • How to save uploaded file in JSF
    0 讨论(0)
提交回复
热议问题