acid
RSS FEED
Home
Tag
MediaLog
LocationLog
Guestbook
Admin
Write
sidebar open
sidebar close
에시드
쌈마이코더
달력
이전
다음
2026.2
일
월
화
수
목
금
토
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
Total
Today
Yesterday
카테고리
미분류
(104)
source code
(3)
tistory TIP
(1)
project
(4)
image
(1)
BIG
(0)
small
(0)
medium
(0)
DB
(25)
RFC
(1)
OS
(7)
HPUX
(0)
AIX
(0)
Solaris
(0)
MAC
(1)
JAVA
(15)
C
(0)
linux
(2)
WEB
(2)
EJB
(3)
WAS
(2)
HTML/CSS
(2)
script
(8)
util
(3)
hardware
(16)
vehicle
(4)
공지사항
태그목록
Struts
JSTL
wind schott
javascript
URIEncoding
a207
Performance Mouse MX
a207 wind deflector
70mai pro plus a500
perl
a500 펌웨어
E200 엔진
정규식
M274
WebParser: RegExp matching error
E200 engine
0.0.34ww
select
드라우트 스탑
데이터베이스
mysql
useBodyEncodingForURI
x220t
SQL(Oracle)
개발용 마우스
AWS EC2 OSX
금호kw27
게시판
draught stop
오라클
최근에 올라온 글
최근에 달린 댓글
최근에 받은 트랙백
글 보관함
링크
acid.
파일업로드 관련 및 스크립트 이미지처리
2009. 3. 11. 20:42
from
source code
this.processUpload(requestInfo, uploadpath, imgFileName); //파일 업로드 public void processUpload(RequestInfo requestInfo, String uploadpath, String imgFileName) throws IllegalAccessException { FileItem[] items = requestInfo.getFileItems(); FileItem fileItem = items[0]; if ( fileItem != null ) { if ( ( imgFileName != null ) && ( !imgFileName.equals("") ) ) { doFileUploadDBFileName( fileItem, String.valueOf(0), uploadpath, requestInfo, imgFileName); } } }
//파일의 확장자만 셋팅한다. public String setFileExtension(RequestInfo requestInfo, Map<String, String> vo) { FileItem[] items = requestInfo.getFileItems(); for ( int i=0 ; i<items.length ; i++ ) { FileItem fileItem = items[i]; if ( fileItem != null ) { String fileName = fileItem.getFileName(); // add by String temp[] = fileName.split("[.]") ; String fileExtension = "." + temp[temp.length -1] ; vo.put("imgFileName", fileExtension); return fileExtension; } } return null; }
// 파일명을 upload public static void doFileUploadDBFileName(FileItem fileItem, String file_count, String uploadpath, RequestInfo requestInfo, String fileName) throws FileNotFoundException, IOException { System.out.println("================= FileUpload Start ================="); InputStream stream = fileItem.getInputStream() ; OutputStream bos = new FileOutputStream(uploadpath + fileName); System.out.println("================ File Name =================>" + uploadpath + fileName); int bytesRead = 0; byte[] buffer = new byte[8192]; while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) { bos.write(buffer, 0, bytesRead); } bos.close(); stream.close(); System.out.println("================= FileUpload End ================="); }
// javaScript function imgCheck(img, location) { if (img.length > 0) { idx = img.lastIndexOf("\\"); filename = img.substring(idx+1); idx2 = filename.lastIndexOf("."); ext = filename.substring(idx2+1); ext2 = ext.toLowerCase(); if ( ext2 == "bmp" || ext2 == "jpg" || ext2 == "gif" || ext2 == "jpeg" || ext2 == "png" ) { return true; } else { alert(location + '는(은) 이미지 파일 형식이 아닙니다.\n확인해 주시기 바랍니다.'); return false; } } else { alert(location + '를 첨부해 주세요.'); return false; } }
공유하기
게시글 관리
acid
'
source code
' 카테고리의 다른 글
JNDI(Java Naming and Directory Interface)
(0)
2009.03.11
[JAVA Script] 스크립트 모음집
(0)
2009.03.11
Posted by
에시드
:
티스토리툴바