Commit 11b7c72a by 黎配弘

尝试修复路径遍历的问题

parent 480fbe41
...@@ -186,21 +186,17 @@ public class PackageController extends BaseController { ...@@ -186,21 +186,17 @@ public class PackageController extends BaseController {
@Permission(menuname = "上传背景图", value = "backgroundUpload", method = RequestMethod.POST) @Permission(menuname = "上传背景图", value = "backgroundUpload", method = RequestMethod.POST)
public ResponseData<String> backgroundUpload(@RequestParam(value = "file") MultipartFile file, @RequestParam(value = "id", required = false) int id) { public ResponseData<String> backgroundUpload(@RequestParam(value = "file") MultipartFile file, @RequestParam(value = "id", required = false) int id) {
String subfix = ""; StringBuilder basePath = new StringBuilder();
String backgroundpath = FilePath.BACKGROUNDIMG.getValue() + "/" + DEFAULTPATH + "/"; basePath.append(FilePath.BACKGROUNDIMG.getValue()).append(File.separator).append(DEFAULTPATH).append(File.separator);
if (id < 1) { if (id < 1) {
EntityWrapper<Package> packagewrapper = new EntityWrapper<>(); EntityWrapper<Package> packagewrapper = new EntityWrapper<>();
packagewrapper.setSqlSelect("max(id) as id"); packagewrapper.setSqlSelect("max(id) as id");
List<Map<String, Object>> selectMaps = packageMapper.selectMaps(packagewrapper); List<Map<String, Object>> selectMaps = packageMapper.selectMaps(packagewrapper);
id = Integer.parseInt(selectMaps.get(0).get("id").toString()); basePath.append(Integer.parseInt(selectMaps.get(0).get("id").toString()) + 1);
Integer fileid = id + 1;
subfix = fileid.toString();
} else { } else {
subfix = String.valueOf(id); basePath.append(id);
} }
backgroundpath = backgroundpath + subfix.replace(".", ""). File dir = new File(basePath.toString());
replace("/", "").replace("\\", "");
File dir = new File(backgroundpath);
if (!dir.exists()) { if (!dir.exists()) {
dir.mkdirs(); dir.mkdirs();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment