ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
~~~ package com.nobb.controller.admin; import com.nobb.util.Response; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; import java.io.File; import java.io.IOException; import java.util.Map; @Controller public class UploadController { @RequestMapping("/upload") @ResponseBody public Map upload(@RequestParam("file") MultipartFile file){ System.out.println(file); if (file.isEmpty()) { return Response.error(400, "error"); } String fileName = file.getOriginalFilename(); String filePath = "D:/temp/"; File dest = new File(filePath + fileName); try { file.transferTo(dest); return Response.msg(0,null,"success"); } catch (IOException e) { } return Response.error(400, "error"); } } ~~~