【问题标题】:how to get browsed file location by user when he wants to download a file当用户想要下载文件时如何获取用户浏览的文件位置
【发布时间】:2014-09-16 12:17:51
【问题描述】:

这是我的 html 代码,用于让用户下载文件并点击控制器

window.location.href="@routes.ListManagementController.downloadList("+listName+")?listname="+listName;

这是我的控制器代码:

String listName = Form.form().bindFromRequest().get("listname");
        response().setContentType("application/x-download"); 
        response().setHeader("Content-disposition", "attachment;filename="+listName+"_data_export.csv");

以上两个respose()语句弹出下载文件我要浏览的文件位置

      File file = new File("C:/csv/" + filename);

因此,使用 servlet api,我们可以使用 respose.getOutputStream() 方法将内容写入浏览的文件位置。在游戏中不支持 servlet。我希望用户选择浏览的文件位置,以便我可以将该位置提供给File 并将文件写入那里。

【问题讨论】:

    标签: playframework-2.3


    【解决方案1】:

    您无法获取客户端上目录的位置,即使您可以,您的服务器端也无法对其进行写入(因为它通常位于另一台计算机上)。

    【讨论】:

      猜你喜欢
      • 2017-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-17
      • 1970-01-01
      • 2019-04-07
      • 1970-01-01
      相关资源
      最近更新 更多