不知道下面兩個文件有沒有幫助Openfile.jsp
++++++++++++++++
<%@ page contentType="text/html; charset=big5" %>
<html>
<head>
<%
String testPath = request.getParameter("testPath")==null?"":request.getParameter("testPath").trim();
%>
<title>openfile</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>
</head>
<%if(!testPath.equals("")){%>
<body onLoad="MM_goToURL('parent','../Openfile?file_name=<%=testPath%>');return document.MM_returnValue">
</body> <%}%>
</html>
++++++++++++++++++++++++
Open.jsp
+++++++++++++++++++++++++
<%@ page import="java.io.*,pursue.com.util.Globals"%>
<%
String filename = request.getParameter("testPath")==null?"":request.getParameter("testPath").trim();
String ext=filename.substring(filename.lastIndexOf(".")+1);
String file_name = filename.substring(filename.lastIndexOf("/")+1);
//response.reset();response.setContentType("application/OCTET-STREAM");
response.setHeader("Content-Disposition", "attachment; filename="+file_name);
filename = Globals.RTC_UP_PATH + "/" + filename;
File f = new File(filename); // the zip file
FileInputStream fin = new FileInputStream(f);
// write the chart data
OutputStream output = response.getOutputStream();
byte[] buf = new byte[1024];
int r = 0;
while((r = fin.read(buf, 0, buf.length))!= -1) {
output.write(buf, 0, r);
}
fin.close();
%>
++++++++++++++++
<%@ page contentType="text/html; charset=big5" %>
<html>
<head>
<%
String testPath = request.getParameter("testPath")==null?"":request.getParameter("testPath").trim();
%>
<title>openfile</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>
</head>
<%if(!testPath.equals("")){%>
<body onLoad="MM_goToURL('parent','../Openfile?file_name=<%=testPath%>');return document.MM_returnValue">
</body> <%}%>
</html>
++++++++++++++++++++++++
Open.jsp
+++++++++++++++++++++++++
<%@ page import="java.io.*,pursue.com.util.Globals"%>
<%
String filename = request.getParameter("testPath")==null?"":request.getParameter("testPath").trim();
String ext=filename.substring(filename.lastIndexOf(".")+1);
String file_name = filename.substring(filename.lastIndexOf("/")+1);
//response.reset();response.setContentType("application/OCTET-STREAM");
response.setHeader("Content-Disposition", "attachment; filename="+file_name);
filename = Globals.RTC_UP_PATH + "/" + filename;
File f = new File(filename); // the zip file
FileInputStream fin = new FileInputStream(f);
// write the chart data
OutputStream output = response.getOutputStream();
byte[] buf = new byte[1024];
int r = 0;
while((r = fin.read(buf, 0, buf.length))!= -1) {
output.write(buf, 0, r);
}
fin.close();
%>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货