文件上传接口新增原/新文件名返回参数

This commit is contained in:
RuoYi
2022-02-24 15:17:55 +08:00
parent 85677a3349
commit 72540d01ab
3 changed files with 40 additions and 8 deletions

View File

@ -253,4 +253,22 @@ public class FileUtils
}
return strFileExtendName;
}
/**
* 获取名称
*
* @param fileName 路径名称
* @return 没有文件路径的名称
*/
public static String getName(String fileName)
{
if (fileName == null)
{
return null;
}
int lastUnixPos = fileName.lastIndexOf('/');
int lastWindowsPos = fileName.lastIndexOf('\\');
int index = Math.max(lastUnixPos, lastWindowsPos);
return fileName.substring(index + 1);
}
}