File tree 2 files changed +45
-0
lines changed
java/way/presentation/admin/controller
2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -11,4 +11,10 @@ public String getPolicyPage() {
11
11
return "policy" ;
12
12
}
13
13
14
+ @ GetMapping ("/upload" )
15
+ public String upload () {
16
+
17
+ return "upload" ;
18
+ }
19
+
14
20
}
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html xmlns:th ="http://www.thymeleaf.org ">
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < title > 이미지 업로드</ title >
6
+ < script src ="https://code.jquery.com/jquery-3.6.0.min.js "> </ script >
7
+ </ head >
8
+ < body >
9
+ < h2 > 이미지 업로드</ h2 >
10
+ < form id ="uploadForm " enctype ="multipart/form-data ">
11
+ < label for ="homeImage "> 이미지 선택:</ label >
12
+ < input type ="file " id ="homeImage " name ="homeImage " accept ="image/* " required >
13
+ < button type ="submit "> 업로드</ button >
14
+ </ form >
15
+
16
+ < script >
17
+ $ ( document ) . ready ( function ( ) {
18
+ $ ( '#uploadForm' ) . on ( 'submit' , function ( event ) {
19
+ event . preventDefault ( ) ;
20
+ let formData = new FormData ( this ) ;
21
+
22
+ $ . ajax ( {
23
+ url : '/admin/image' ,
24
+ type : 'POST' ,
25
+ data : formData ,
26
+ processData : false ,
27
+ contentType : false ,
28
+ success : function ( response ) {
29
+ alert ( '이미지 업로드 성공!' ) ;
30
+ } ,
31
+ error : function ( xhr , status , error ) {
32
+ alert ( '업로드 실패: ' + xhr . responseText ) ;
33
+ }
34
+ } ) ;
35
+ } ) ;
36
+ } ) ;
37
+ </ script >
38
+ </ body >
39
+ </ html >
You can’t perform that action at this time.
0 commit comments