master
ck 5 years ago
parent abee56bbf6
commit 404f291559

@ -16,6 +16,8 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@ -79,4 +81,28 @@ public class CaseContentAttachmentController {
}
@RequestMapping(value="upload", produces = "text/html;charset=UTF-8")
public void testUpload(MultipartFile file) throws IOException {
if (file.isEmpty()) {
System.out.println("没文件");
}
//文件名称
String realFileName = file.getOriginalFilename();
String path ="D:/cktest/";
//检查该路径对应的目录是否存在. 如果不存在则创建目录
File dir=new File(path);
if (!dir.exists()) {
dir.mkdirs();
}
String filePath = path + realFileName;
System.out.println("filePath: "+filePath);
//保存文件
File dest = new File(filePath);
if (!(dest.exists())) {
file.transferTo(dest);
}
}
}

Loading…
Cancel
Save