download.jsp~6~
上传用户:dlqqsh
上传日期:2021-11-13
资源大小:7840k
文件大小:1k
源码类别:

OA系统

开发平台:

Java

  1. <%@ page contentType="text/html; charset=GBK" import="com.jspsmart.upload.*" %>
  2. <% request.setCharacterEncoding("UTF8");%>
  3. <html>
  4. <head>
  5. <title>
  6. download
  7. </title>
  8. </head>
  9. <body bgcolor="#ffffff">
  10. <h4>
  11. download
  12. </h4>
  13. <%
  14. //String fn = request.getParameter("fn");
  15. /*
  16. out.print(fn+" is being donwloaded!");
  17. String fnn = (String)session.getAttribute("fna");
  18. out.print(fnn+" is being downloaded too!");
  19. session.removeAttribute("fna");*/
  20. try{
  21.   // 新建一个SmartUpload对象
  22.   SmartUpload su = new SmartUpload();
  23.   // 初始化
  24.   su.initialize(pageContext);
  25.   String fn = request.getParameter("fn");
  26.   out.print(fn);
  27.   if(fn==null){
  28.     out.print("file name is null,please try again!");
  29.   }else{
  30.     // 设定contentDisposition为null以禁止浏览器自动打开文件,
  31.     //保证点击链接后是下载文件。若不设定,则下载的文件扩展名为
  32.     //doc时,浏览器将自动用word打开它。扩展名为pdf时,
  33.     //浏览器将用acrobat打开。
  34.     su.setContentDisposition(null);
  35.     // 下载文件
  36.     String nfn = su.toUtf8String(fn);
  37.     su.downloadFile("/upload/"+nfn);
  38.   }
  39. }catch(Exception ex){
  40.   ex.printStackTrace();
  41. }finally{
  42.   out.clear();
  43.   out = pageContext.pushBody();
  44. }
  45. %>
  46. <a href=FileUpload.html>重新上传</a>
  47. </body>
  48. </html>