如何在用户下载文件时浏览文件位置

时间:2014-09-16 12:17:51

标签: playframework-2.3

这是我的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并在那里写入文件。

1 个答案:

答案 0 :(得分:1)

您无法获取客户端上目录的位置,即使可以,您的服务器端也无法写入该目录(因为它通常位于不同的计算机上) )。