类似type="file"不过不是打开文件夹,而是打开目录。点击保存按钮的。

解决方案 »

  1.   

    <input type="file" name="mf">
    <input type="submit" value="上传">
      

  2.   

    response.setContentType("application/x-msdownload");
    response.setHeader("Content-disposition","attachment; filename=测试的.txt");
      

  3.   

    input[file] 不能选择目录,只能选择文件后 把文件名去掉来取得目录
      

  4.   

    你是说上传一个文件夹目录中的所有文件吧。这个好像要用flash吧。
      

  5.   

    希望有“保存文件”那样的对话框。   
    ------------------- 这不就是弹出下载文件对话框吗 写个servlet调用我这个方法 (PS:非本人所写,该方法由layueer写的)
    本人拿来借用而已 private   void   down_FILE(HttpServletRequest   req,HttpServletResponse   resp,String   szPath_file,String   szFile_name) 
            { 
                    String     szServer_path= " "; 
                    szServer_path=szPath_file; 
                    BufferedInputStream     bis   =   null; 
                    BufferedOutputStream   bos   =   null; 
                    try 
                    { 
                          //和java.io.PrintWriter   out   不能共用 
                            ServletOutputStream   outm   =   null; 
                            try 
                            { 
                                    outm=resp.getOutputStream(); 
                            } 
                            catch(Exception   e) 
                            { 
                                      exceptionOutput(resp,e.toString()+ "   abcd "); 
                            } 
                            resp.setContentType(   "application/octet-stream "   );   //   MIME   type   for   exe 
                            resp.setHeader( "Content-disposition ", "attachment;   filename= "+szFile_name);//显示的随机文件名,可以用这个保存或另起一个名 
                            //   Open   file 
                            File   f1; 
                            szServer_path   =   szServer_path+ "filename.xls "   ; 
                            try 
                            { 
                                    f1=new   File(szServer_path); 
                                    FileInputStream   fis=new   FileInputStream(f1); 
                                    bis   =   new   BufferedInputStream(fis); 
                                    bos   =   new   BufferedOutputStream(outm); 
                                    byte[]   buff   =   new   byte[2048]; 
                                    int   bytesRead; 
                                    while(-1   !=   (bytesRead   =   bis.read(buff,   0,   buff.length))) 
                                    { 
                                            bos.write(buff,   0,   bytesRead); 
                                    }                         } 
                            catch(Exception   e) 
                            { 
                            } 
                    } 
                    finally 
                    { 
                            try 
                            { 
                                    if   (bis   !=   null)   bis.close(); 
                                    if   (bos   !=   null)   bos.close(); 
                            } 
                            catch(IOException   e) 
                            { 
                            } 
                    } 
            }
      

  6.   

    servlet不能用啊,我用的struts2框架,会被拦截的
      

  7.   

    import org.apache.commons.fileupload.FileItem;
    import org.apache.commons.fileupload.FileUploadException;
    import org.apache.commons.fileupload.disk.DiskFileItemFactory;
    import org.apache.commons.fileupload.servlet.ServletFileUpload;
    上传、下载你可以下commons包,当然也可以别
    servlet中代码:
                  //防止路径中有汉字
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    //判断是否multipart模式
    boolean flag = ServletFileUpload.isMultipartContent(request);
    if(flag){
    DiskFileItemFactory factory = new DiskFileItemFactory();         factory.setSizeThreshold(4096);

            ServletFileUpload upload = new ServletFileUpload(factory);         upload.setSizeMax(1000000);

            Iterator i = null;
    try {
    i = upload.parseRequest(request).iterator();
    } catch (FileUploadException e1) {
    e1.printStackTrace();
    }
            while(i.hasNext()){
            FileItem fi = (FileItem)i.next();
            
            String fileName = fi.getName();
           
            try {
             String name = fileName.substring( fileName.lastIndexOf("\\")+1,fileName.length());
             String realpath =request.getRealPath("/uploadFill");
             String ContextPath =request.getContextPath();
             String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+ContextPath+"/";
             String remoteAddr = request.getRemoteAddr();
             String LocalAddr = request.getLocalAddr();          Date date = new Date();
            
             String filename=date.getYear()+date.getMonth()+date.getDay()+date.getHours()+date.getMinutes()+date.getSeconds()+name;
             System.out.println(filename);
             System.out.println(date.getYear()+""+date.getMonth()+date.getDay()+date.getHours());
             String filepath=realpath+File.separatorChar+filename;
             System.out.println("filepath:"+filepath);
             //// write直接输出
             fi.write(new File(realpath, filename));
                      request.getSession().setAttribute("iamge", "uploadFill/"+filename);
             System.out.println("uploadFill/"+filename);
             request.getRequestDispatcher("MyFillUpLoad.jsp").forward(request, response);
            
            
            
    } catch (Exception e) {

    e.printStackTrace();
    }
            }
    }else{

    System.out.println("否multipart模式");
    }
      

  8.   

    其实如果是下载。rar或者是看图片,直接写response.sendRedirect(“你得到的目录”);就可以
      

  9.   

    其实我只是想获得C:\backup\leadpdb20120917.dmp这样的东西。当然不能手动敲进去