<%@ page language="java" %>
<%@ page session="true" %>
<%@ page isThreadSafe="true" %>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="java.io.*,java.util.*" %>
<%
String fileReallyName = request.getParameter("file");
File zipFile = new File(fileReallyNam);
if(!zipFile.exist()){
out.print("檔案不存在");
return;
}
response.setContentType("application/x-msdownload; charset=gb2312");
response.setHeader("Content-disposition", "attachment;filename=/"" + new String(fileReallyName.getBytes("GBK"),"ISO8859-1") + "/"");
FileInputStream fis = null;
ByteArrayOutputStream bos = null;
try
{
fis = new FileInputStream(zipFile);
bos = new ByteArrayOutputStream(8192);
int readline;
byte[] b = new byte[1024];
while((readline=fis.read(b))!=-1)
bos.write(b,0,readline);
bos.writeTo(response.getOutputStream());
out.clear();
out = pageContext.pushBody();
}catch(IOException e)
{
out.print("下載出錯"+e.getMessage());
}finally{
try{
if(fis!=null) fis.close();
if(bos!=null) bos.close();
}catch(Exception e){
out.print("關閉檔案流失敗");
}
}
%>