중간커밋
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
<%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%>
|
||||
<%@ page import="java.util.*, java.io.*" %>
|
||||
<%@include file= "/init.jsp" %>
|
||||
<%
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%@ page import="java.util.*, java.io.*"%><%@include file="/init.jsp"%><%
|
||||
|
||||
HashMap map = (HashMap)request.getAttribute("FILE_MAP");
|
||||
if(map == null) map = new HashMap();
|
||||
@@ -20,10 +17,32 @@ if(!"".equals(realFileName)){
|
||||
realFileName = (java.net.URLEncoder.encode(realFileName, "UTF-8")).replaceAll("\\+", " ");
|
||||
}
|
||||
|
||||
String fullFilePath = filePath+"\\"+savedFileName;
|
||||
// 파일 경로 생성
|
||||
// savedFileName이 구분자로 시작하면 그대로 합치고, 아니면 구분자 추가
|
||||
String fullFilePath = "";
|
||||
if(savedFileName.startsWith("/") || savedFileName.startsWith("\\")){
|
||||
fullFilePath = filePath + savedFileName;
|
||||
} else {
|
||||
fullFilePath = filePath + File.separator + savedFileName;
|
||||
}
|
||||
System.out.println("fullFilePath : "+fullFilePath);
|
||||
System.out.println("filePath : "+filePath);
|
||||
System.out.println("savedFileName : "+savedFileName);
|
||||
System.out.println("realFileName : "+realFileName);
|
||||
|
||||
File f = new File(fullFilePath);
|
||||
File f = new File(fullFilePath);
|
||||
|
||||
// 파일이 없으면 기존 방식(역슬래시 포함)으로 시도
|
||||
if(!f.exists()){
|
||||
String legacyFilePath = filePath + "\\" + savedFileName;
|
||||
System.out.println("Trying legacy path : "+legacyFilePath);
|
||||
File legacyFile = new File(legacyFilePath);
|
||||
if(legacyFile.exists()){
|
||||
f = legacyFile;
|
||||
fullFilePath = legacyFilePath;
|
||||
System.out.println("Found with legacy path!");
|
||||
}
|
||||
}
|
||||
if(f.exists()){
|
||||
|
||||
int filesize = (int)f.length();
|
||||
@@ -36,8 +55,15 @@ if(f.exists()){
|
||||
|
||||
//response.setContentType("text/plain; charset=EUC_KR");
|
||||
//response.setContentType("application/x-msdownload");
|
||||
response.setContentType("application/octet-stream;charset=euc-kr");
|
||||
response.setHeader("Content-Disposition", "attachment; filename="+ realFileName);
|
||||
|
||||
// PDF 파일이면 미리보기 모드로
|
||||
if("PDF".equalsIgnoreCase(fileExt)){
|
||||
response.setContentType("application/pdf");
|
||||
response.setHeader("Content-Disposition", "inline; filename="+ realFileName);
|
||||
}else{
|
||||
response.setContentType("application/octet-stream;charset=utf-8");
|
||||
response.setHeader("Content-Disposition", "attachment; filename="+ realFileName);
|
||||
}
|
||||
FileInputStream fin = new java.io.FileInputStream(f);
|
||||
BufferedInputStream bis = new BufferedInputStream(fin);
|
||||
ServletOutputStream fout = response.getOutputStream();
|
||||
@@ -62,13 +88,11 @@ if(f.exists()){
|
||||
//file download log 2015-12-22 jmpark end
|
||||
|
||||
} catch( IOException e){
|
||||
response.setContentType("text/html; charset=EUC_KR");
|
||||
response.setContentType("text/html; charset=UTF-8");
|
||||
out.println("Error : "+e.getMessage());
|
||||
}
|
||||
}else{
|
||||
response.setContentType("text/html; charset=EUC_KR");
|
||||
response.setContentType("text/html; charset=UTF-8");
|
||||
out.println("File Not Found : " + fullFilePath);
|
||||
}
|
||||
|
||||
|
||||
%>
|
||||
}
|
||||
%>
|
||||
Reference in New Issue
Block a user