<%@ page contentType="text/html" pageEncoding="euc-kr"%>
<%@page import="java.util.*,java.io.*"%>
<%
String filepath = request.getRealPath("/upload") + "\\";
String filename = request.getParameter("fileName");
//System.out.println(filepath + "----" + filename);
byte b[] = new byte[600];
File files = new File(filepath + filename);
if (!files.exists()) {
%>
<script>
alert('해당 파일이 존재하지 않습니다!');
window.history.back();
</script>
<%
} else {
OutputStream outStream = response.getOutputStream();
response
.setContentType("application/x-msdownload;charset=UTF-8");
response.setHeader("content-disposition",
"attachment;filename=" + filename);
FileInputStream in = new FileInputStream(files);
int n = 0;
while ((n = in.read(b)) != -1) {
outStream.write(b, 0, n);
}
in.close();
outStream.flush();
outStream.close();
out.clear();
out = pageContext.pushBody();
}
%>
posted on 2008-12-15 17:09
长春语林科技 阅读(195)
评论(0) 编辑 收藏 所属分类:
util