Notice
														
												
											
												
												
													Link
													
											
												
												- Today
 
- Total
 
													Recent Posts
													
											
												
												
													Recent Comments
													
											
									| 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 | 
| 9 | 10 | 11 | 12 | 13 | 14 | 15 | 
| 16 | 17 | 18 | 19 | 20 | 21 | 22 | 
| 23 | 24 | 25 | 26 | 27 | 28 | 29 | 
| 30 | 
													Tags
													
											
												
												- 피쉬랜드
 - ffmpeg
 - c언어
 - 가변영역 스크롤
 - vc++
 - SQL
 - MySQL
 - Back 키 클릭 감지
 - mybatis exception
 - 스크롤적용
 - sql exception
 - group by
 - 말줌임 CSS
 - 터치좌표 view
 - view 획득
 - MFC
 - CSS
 - MariaDB
 - springboot
 - Activity 전체화면
 - springboot 재가동
 - pid 찾아 kill
 - CentOS
 - 시간대 테이블생성
 - reactnative
 - kill -9
 - 시간대별 통계
 - 코드로 서버 재실행
 - 파티션 빠른 삭제
 - rn
 
													Archives
													
											
									개발은 하는건가..
[Springboot] 파일 업로드 본문
반응형
    
    
    
  
사진 파일 업로드 예)
@ResponseBody
@PostMapping("/api/photo/upload")
public String photoUpload(@RequestParam(required = false) MultipartFile uploadFile) throws IOException {
        
        String extFileName = uploadFile.getOriginalFilename().toUpperCase();
        if (extFileName.endsWith("JPG") == false) {
            return "Jpg 파일만 지원합니다";
        }
        int fileSize = uploadFile.getBytes().length;
        try {
            File dirFile = new File("파일 저장 경로");
            if (dirFile.exists() == false) {
                dirFile.mkdir();
            }
            
            File photoFile = new File("파일명을 포함한 저장 경로");
            uploadFile.transferTo(photoFile);            
        }
        catch (Exception e) {
        	e.printStackTrace();
            return "업로드 실패";            
        }
       
        return "성공";
    }'SpringBoot , Thymeleaf' 카테고리의 다른 글
| [Springboot] jar 파일을 exe 파일로 만들기 (0) | 2023.02.13 | 
|---|---|
| [Springboot] 파일 다운로드 (0) | 2023.01.30 | 
| [Srpingboot] Multipart file upload size limit 설정 (0) | 2023.01.06 | 
| [Springboot] IntelliJ 개발 환경 속도 향상 (0) | 2023.01.05 | 
| Springboot 외부 경로의 리소스 또는 업로드 파일 접근 (0) | 2022.12.14 | 
			  Comments