hyeonga_code

Project_AWS_S3_서버에 이미지 업로드 프로젝트에 적용하기 ver.1 본문

Project_WEATHERWEAR

Project_AWS_S3_서버에 이미지 업로드 프로젝트에 적용하기 ver.1

hyeonga 2024. 1. 3. 07:59
반응형

시도 1. S3 서버에만 업로드하기

========

1. pom.xml 파일에 aws-java-sdk-s3 라이브러리 추가

<!-- AWS S3에 파일 업로드 라이브러리 시작 -->
		<dependency>
			<groupId>com.amazonaws</groupId>
			<artifactId>aws-java-sdk-s3</artifactId>
			<version>1.11.901</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
		<dependency>
		    <groupId>com.fasterxml.jackson.core</groupId>
		    <artifactId>jackson-databind</artifactId>
		    <version>2.15.2</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-xml -->
		<dependency>
		    <groupId>com.fasterxml.jackson.dataformat</groupId>
		    <artifactId>jackson-dataformat-xml</artifactId>
		    <version>2.15.1</version>
		</dependency>
<!-- AWS S3에 파일 업로드 라이브러리 끝 -->

 

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.w2</groupId>
    <artifactId>w2</artifactId>
    <name>weatherwear</name>
    <packaging>war</packaging>
    <version>1.0.0-BUILD-SNAPSHOT</version>
    <properties>
        <java-version>11</java-version>
        <org.springframework-version>5.3.27</org.springframework-version>
        <org.aspectj-version>1.9.19</org.aspectj-version>
        <org.slf4j-version>2.0.7</org.slf4j-version>
    </properties>
    <dependencies>
    <!-- 기본 설정 파일 시작 -->
<!-- Spring-context -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework-version}</version>
            <exclusions>
                <!-- Exclude Commons Logging in favor of SLF4j -->
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
<!-- spring-webmvc -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>
 
<!-- Aspectrt -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>${org.aspectj-version}</version>
        </dependency>
 
    <!-- Logging -->
<!-- slf4j-api -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${org.slf4j-version}</version>
        </dependency>
<!-- jcl-over-slf4j -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
<!-- slf4j-version -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
<!-- log4j -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.15</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.mail</groupId>
                    <artifactId>mail</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.jms</groupId>
                    <artifactId>jms</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jdmk</groupId>
                    <artifactId>jmxtools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jmx</groupId>
                    <artifactId>jmxri</artifactId>
                </exclusion>
            </exclusions>
            <scope>runtime</scope>
        </dependency>
 
        <!-- @Inject -->
<!-- javax.inject -->
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>
 
    <!-- Servlet -->
<!-- javax.servlet-api -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>4.0.0</version>
            <scope>provided</scope>
        </dependency>
<!-- javax.servlet.jsp-api -->
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>javax.servlet.jsp-api</artifactId>
            <version>2.3.3</version>
            <scope>provided</scope>
        </dependency>
<!-- jstl -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
 
        <!-- Test -->
<!-- junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>
    <!-- 기본 설정 파일 끝 -->
    
    <!-- Mybatis 연동 시작 -->
<!-- mybatis -->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.5.13</version>
        </dependency>
<!-- mybatis-spring -->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>2.1.0</version>
        </dependency>
    <!-- Mybatis 연동 끝 -->
    
    <!-- AWS RDS : 연동 시작 -->
<!-- mysql-connector-java : MySQL 연결 라이브러리 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.33</version>
        </dependency>
 
<!-- spring-jdbc : 데이터베이스와 연결하는 라이브러리 -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>    
    <!-- AWS RDS : 연동 끝 -->
    
<!-- commos-dbcp2 -->
        <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-dbcp2</artifactId>
                <version>2.10.0</version>
        </dependency>    
        
    <!-- MyBatis 연동 시작 -->
<!-- mybatis -->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.5.13</version>
        </dependency>
<!-- mybatis-spring -->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>2.1.0</version>
        </dependency>    
    <!-- MyBatis 연동 끝 -->
 
<!-- 파일 업로드 라이브러리 시작 -->
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.5</version>
        </dependency>
        
        <!-- commons-io -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
        </dependency>
<!-- 파일 업로드 라이브러리 끝 -->
 
<!-- lombok -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.22</version>
            <scope>provided</scope>
        </dependency>
 
<!-- json-simple : JSON 작업을 위해 필요한 라이브러리 시작 -->
        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1.1</version>
        </dependency>
<!-- json-simple : JSON 작업을 위해 필요한 라이브러리 끝 -->
 
<!-- Email 인증번호 발급 적용 시작 -->
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-email -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-email</artifactId>
            <version>1.5</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/javax.mail/mail -->
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.7</version>
        </dependency>
        
        <!-- https://mvnrepository.com/artifact/com.google.apis/google-api-services-gmail -->
        <dependency>
            <groupId>com.google.apis</groupId>
            <artifactId>google-api-services-gmail</artifactId>
            <version>v1-rev110-1.25.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.google.oauth-client/google-oauth-client-jetty -->
        <dependency>
            <groupId>com.google.oauth-client</groupId>
            <artifactId>google-oauth-client-jetty</artifactId>
            <version>1.34.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.google.http-client/google-http-client-jackson2 -->
        <dependency>
            <groupId>com.google.http-client</groupId>
            <artifactId>google-http-client-jackson2</artifactId>
            <version>1.42.3</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.google.http-client/google-http-client -->
        <dependency>
            <groupId>com.google.http-client</groupId>
            <artifactId>google-http-client</artifactId>
            <version>1.43.3</version>
        </dependency>
<!-- Email 인증번호 발급 적용 끝 -->
 
<!-- AWS S3에 파일 업로드 라이브러리 시작 -->
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-s3</artifactId>
            <version>1.11.901</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.15.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-xml -->
        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-xml</artifactId>
            <version>2.15.1</version>
        </dependency>
<!-- AWS S3에 파일 업로드 라이브러리 끝 -->
<!-- 암호화 라이브러리 시작 5.7.5-->
        <!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-core -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>5.7.5</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-web -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>5.7.5</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-config -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>5.7.5</version>
        </dependency>
<!-- 암호화 라이브러리 시작 -->
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <additionalProjectnatures>
                        <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                    </additionalProjectnatures>
                    <additionalBuildcommands>
                        <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                    </additionalBuildcommands>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.1</version>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                    <compilerArgument>-Xlint:all</compilerArgument>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <mainClass>org.test.int1.Main</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

 

 

2. com.w2.file 패키지 생성하기

3. 패키지에 AwsS3 클래스 생성하기

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package com.w2.file;
 
import java.io.File;
import java.io.InputStream;
 
import org.springframework.stereotype.Repository;
 
import com.amazonaws.AmazonServiceException;
import com.amazonaws.SdkClientException;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.ObjectMetadata;
import com.amazonaws.services.s3.model.PutObjectRequest;
 
@Repository
public class AwsS3 {
 
    private AmazonS3 s3Client;
    
    // AWS S3 사용하기 위한 IAM 정보(hyeongaIAM)
    final private String ACCESSKEY = "엑세스 키";
    final private String SECRETKEY = "시크릿 키";
    
    private Regions clientRegion = Regions.AP_NORTHEAST_2;
    
    // S3 버킷 이름
    private String bucket = "버킷 이름";
    
    private AwsS3() {
        createS3Client();
    }
    
    static private AwsS3 instance = null;
    
    public static AwsS3 getInstance() {
        if(instance == null) {
            return new AwsS3();
        } else {
            return instance;
        }
    }
    
    // aws S3 Client 생성
    private void createS3Client() {
        AWSCredentials credentials = new BasicAWSCredentials(ACCESSKEY, SECRETKEY);
        
        this.s3Client = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(credentials)).withRegion(clientRegion).build();
    }
    
    // 파일 하나 업로드
    public void upload(File file, String key) {
        uploadToS3(new PutObjectRequest(this.bucket, key, file));
    }
    
    // 여러 파일 업로드
    public void upload(InputStream is, String key, String contentType, long contentLength) {
        System.err.println("[ AwsS3 ] : upload()");
        ObjectMetadata objectMetadata = new ObjectMetadata();
        
        objectMetadata.setContentType(contentType);
        objectMetadata.setContentLength(contentLength);
        
        uploadToS3(new PutObjectRequest(this.bucket, key, is, objectMetadata));
    }
    
    // 파일 업로드 메소드
    public void uploadToS3(PutObjectRequest putObjectRequest) {
        System.err.println("[ AwsS3 ] : uploadToS3");
        
        try {
            this.s3Client.putObject(putObjectRequest);
            System.out.println(String.format("[%s] upload complete", putObjectRequest.getKey()));
        } catch (AmazonServiceException e) {
            e.printStackTrace();
        } catch (SdkClientException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 

 

 

4. com.w2.file > FileController.java 클래스 생성

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package com.w2.file;
 
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Iterator;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
 
@Controller
public class FileController {
    @Autowired
    private AwsS3 awsS3 = AwsS3.getInstance();
    
    // 이미지 업로드 페이지 요청(테스트)
    @RequestMapping("/insertCmImage.do")
    public String insertCmImage() {
        System.out.println("[ FileController ] : insertCmImage/get");
        
        return "/test/insert_image";
    }
 
    // 이미지 업로드 요청
    @PostMapping("/insertImage.do")
    public String insertCmImage(MultipartHttpServletRequest request , Model model) throws IOException {
        System.out.println("[ Controller ] : insertCmImage/post");
        
        // 업로드할 파일 기본 저장 위치
        String rootUploadDir = "C:" + File.separator + "Weatherwear";
        
        // 업로드할 파일 임시 저장 폴더 위치 > C:/Weatherwear/
        
        
        /** 이미지 경로 지정 */
        // 고객 이미지 경로 
        File clientDir = new File(rootUploadDir + File.separator + "client_image");
        System.err.println("clientDir : " + clientDir);
        
        // 상품 이미지 경로
        File productDir = new File(rootUploadDir + File.separator + "product_image");
        System.err.println("productDir : " + productDir);
        
        // 관리자 이미지 경로
        File adminDir = new File(rootUploadDir + File.separator + "admin_image");
        System.err.println("adminDir : " + adminDir);
        
        
        // C:/Weatherwear/하위폴더 >>> 본인 컴퓨터에 없는 경우 폴더를 생성합니다.
        if(!clientDir.exists()) {
            clientDir.mkdirs();
        }
        
        // 파일 여러개 받아오기
        Iterator<String> iterator = request.getFileNames();
        
        // 루프
        int fileLoop = 0;
        String uploadFileName;
        
        // 파일 형식 변환
        MultipartFile mFile = null;
        
        // 기본 이름
        String orgFileName = "";
    
        // 서버에 저장할 파일 이름
        String sysFileName = "";
        
        // test
        ArrayList<String> list = new ArrayList<String>();
        
        while(iterator.hasNext()) {
            fileLoop++;
 
            uploadFileName = iterator.next();
            mFile = request.getFile(uploadFileName);
            
            // test
            System.err.println("mFile: " + mFile.toString());
            
            // 파일 원래 이름
            orgFileName = mFile.getOriginalFilename();
            
            // test
            // System.err.println("orgFileName : " + orgFileName);
            // System.err.println("getContentType : " + mFile.getContentType());
            
            if(orgFileName != null && orgFileName.length()!=0) {
                System.out.println("if문 시작");
                
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMDD_");
                Calendar calendar = Calendar.getInstance();
                
                // 파일 이름 YYYYMMDD_원래파일명i.jpg
                sysFileName = simpleDateFormat.format(calendar.getTime()) + orgFileName + fileLoop;
 
                try {
                    System.err.println("local try 시작");
                    
                    mFile.transferTo(new File(clientDir + File.separator + sysFileName + ".jpg"));
                    list.add("원본 이름 : " + orgFileName + ", system : " + sysFileName);
                    
                } catch(Exception e) {
                    list.add("Error");
                    e.printStackTrace();
                }
            }
            
            // S3에 저장할 파일 생성
            File result = new File(clientDir + File.separator + sysFileName+".jpg");
 
            // 업로드 위치 (S3 주소)
            awsS3.upload(result, "client_image/"+sysFileName+".jpg");
            // awsS3.upload(result, "product_image/"+sysFileName+".jpg");
            // awsS3.upload(result, "admin_image/"+sysFileName+".jpg");
            
            
            // test
            // System.err.println("sysFileName : " + sysFileName);
            // System.err.println("result : " + result);
            model.addAttribute("list", list);
            
        }    
        return "/test/get_image";
    }
}
 
 

 

 

5. mybatis-config.xml 파일 추가

servlet-context.xml 파일에 추가

applicationContext.xml 파일에 추가

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?xml version="1.0" encoding="UTF-8"?>
 
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" 
                "http://mybatis.org/dtd/mybatis-3-config.dtd">
 
<configuration>
    
    <typeAliases>
        <!-- typeAlias
                - 매핑파일에서 사용하는 type을 지정
                - 애플리케이션에서 SQL 문으로 값을 전달합니다
                - SQL 문 실행 시 반환되는 레코드를 저장하는 용도로 사용하기 위한 빈을 생성합니다.-->
        <typeAlias type="com.w2.client.ClientVO" alias="client" />
        <typeAlias type="com.w2.client.TestVO" alias="testvo" />
        <typeAlias type="com.w2.file.FileVO" alias="filevo" />
    </typeAliases>
 
    <!-- SQL 작성문을 지정하여 mapper 파일 경로 알려주는 역할입니다. -->
    <mappers>
        <mapper resource="mappings/client-mapping.xml"/>
        <mapper resource="mappings/test-mapping.xml"/>
        <mapper resource="mappings/file-mapping.xml"/>
    </mappers>
</configuration>

 

 

 

6. webapp > WEB-INF > views > test > insert_image.jsp 파일 작성

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
    <form action="insertCmImage.do" method="post" enctype="multipart/form-data">
        <input type="file" name="file1"> 
        <input type="file" name="file2"> 
        <input type="submit" value="insertCmImage.do">
    </form>
</body>
</html>

 

 

 

7. 실행

 

 

 

 

 

>>> 업로드 성공

반응형