【问题标题】:Formfile getFilename and filteringFormfile getFilename 和过滤
【发布时间】:2013-09-20 08:59:28
【问题描述】:

struts的FormFile接口的getFileName()方法是否对文件名进行过滤? Struts documentation for method getfileName

我的意思是,在 Struts documentation for upload 之后,“行动中需要什么”部分。

如果用户提供的文件名是"../../../toto.ext",那么myFile.getFileName() 是返回"toto.ext" 还是"../../../toto.ext"

根据Struts documentation for method getfileName“返回此文件的文件名。这是文件的基本名称,由用户在上传文件时提供。”,它是应该返回"../../../toto.ext"。但我不太确定。

你能告诉我这个问题吗?

【问题讨论】:

    标签: java jsp file-upload upload struts


    【解决方案1】:

    文件名是取自文件夹内容的名称,例如"toto.ext"。但"../../../toto.ext" 不是文件名,它是文件路径,其中包含文件名。路径是相对于当前目录的。您应该区分基本路径名和相对路径。基本路径+文件名给你绝对路径。

    【讨论】:

      猜你喜欢
      • 2022-10-21
      • 2018-09-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-04
      • 1970-01-01
      • 1970-01-01
      • 2020-09-07
      • 1970-01-01
      相关资源
      最近更新 更多