<%@ page import="org.apache.commons.fileupload.*" %>
<%@ page import="org.apache.commons.io.*" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%
eontConfig tc = new eontConfig();
String path = tc.getConfigValue("AttachPathOutBound");
String yyyy = new java.text.SimpleDateFormat ("yyyy").format(new java.util.Date());
String MM = new java.text.SimpleDateFormat ("MM").format(new java.util.Date());
String dd = new java.text.SimpleDateFormat ("dd").format(new java.util.Date());
path = path + "/" + yyyy;
File f = new File(path);
if(!f.isFile()){
if(!f.isDirectory())
f.mkdir();
}
path = path+ "/" +MM;
f = new File(path);
if(!f.isFile()){
if(!f.isDirectory())
f.mkdir();
}
path = path+ "/" +dd;
f = new File(path);
if(!f.isFile()){
if(!f.isDirectory())
f.mkdir();
}
String save_path = "/" + yyyy+ "/" +MM + "/" +dd +"/";
DiskFileUpload upload = new DiskFileUpload();
upload.setSizeMax(10*1024*1024); //파일 업로드 최대 size
upload.setSizeThreshold(4096);//메모리에 저장할 최대 size
upload.setRepositoryPath(path); //파일 임시 저장소
java.util.List items = upload.parseRequest(request);
Iterator iter = items.iterator();
String fileName ="";
long fileSize =0;
while (iter .hasNext()) {
FileItem item = (FileItem)iter .next();
if(item.isFormField()){ //input type="file"이 아닌경우
String name = item.getFieldName();// 필드 이름
String value = item.getString("euc-kr");// 필드 값
// System.out.println(name + "=" + value);
// System.out.println("value=" + value );
if(name.equals("save_name"))
{
fileName = value;
}
}else{ //input type="file" 인경우
fileSize = item.getSize();//파일 사이즈
//실질적인 저장
File file = new File(path + "/" + fileName);
item.write(file);
}
}
save_path = save_path + fileName;
%>
'프로그래밍 > java' 카테고리의 다른 글
이클립스 workspace 변경 파일 (0) | 2012.10.14 |
---|---|
이클립스 시작시 loading workbench eclipse 멈출때 (0) | 2012.10.14 |
[이클립스] 에디터 text 인코딩변경.. (0) | 2012.10.08 |
스프링 applicationContext.xml DB connect 접속 설정 예 (0) | 2012.10.08 |
jsp 파일 다운로드 (0) | 2012.09.18 |
jsp 페이지에서 보안서버 http 로 접근시 --> https 로 이동 (0) | 2012.09.12 |
org.apache.commons.mail 메일 보내기 (0) | 2012.08.16 |
eclipse.ini (0) | 2012.01.13 |
JRebel 연동하기 (0) | 2011.10.28 |
자바형변환 (0) | 2011.10.24 |
댓글