Formfile getFilename和过滤

时间:2013-09-16 09:04:24

标签: java jsp file-upload upload struts

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

我的意思是,遵循Struts documentation for upload,“行动中需要的东西”部分。

如果用户提供的文件名为"../../../toto.ext",则myFile.getFileName()会返回"toto.ext""../../../toto.ext"

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

你能解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

文件名是取自"toto.ext"等文件夹内容的名称。但是"../../../toto.ext"不是文件名,而是文件路径,包括文件名。该路径相对于当前目录。您应该区分基本路径名称和相对路径。基本路径+文件名为您提供绝对路径。

相关问题