<%@page import="java.io.*"%>
<%
String filename = "y3.jpg";
String filepath = "c:\\tom\\webapps\\thumbnail\\";
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition",
"attachment; filename=\"" + filename+"\"");
java.io.FileInputStream fileInputStream = new java.io.FileInputStream(new File(filepath+filename));
int i;
BufferedOutputStream os = new BufferedOutputStream(response.getOutputStream());
while ((i=fileInputStream.read()) != -1) {
os.write(i);
}
fileInputStream.close();
os.close();
%>
It is better to put this code into servlet. If servlet is used, you need a html form, some setting in web.xml and a servlet. You are a beginner, download is not an easy function.
Redxxiv : Some people do not want the file can be downloaded by a hyperlink because they want the download available to the login users. If you use a hyperlink download, people can download it without login.
> Redxxiv : Some people do not want the file can be
> downloaded by a hyperlink because they want the
> download available to the login users. If you use a
> hyperlink download, people can download it without
> login.
Yah, that was right, if he had asked for something specific like that. all he wanted was for a file to be downloaded..
-
Nywled