文件目的地选择器 [英] File Destination Chooser

查看:33
本文介绍了文件目的地选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个文件目的地选择器,就像从浏览器中选择下载文件的保存目的地一样.但我不知道如何弄清楚.

I would like to create a file destination chooser as like choosing save destination of download file from browser. But I have no idea how to figure it out.

我想创建一些文件并将它们保存在用户选择的位置.类似于在 Eclipse IDE 和浏览器中为源文件夹创建新的 Java 类.

I want to create some files and save them at a place that choose from user. Similar with create new Java Class in Eclipse IDE and browser for source folder.

我发现了很多文件上传器,但这些都是浏览特定文件而不是文件夹.

I had found many File-Uploaders but these were browse for specific files not folders.

对我的问题有什么建议吗?我非常感谢您的建议.

Any suggestions for my problem? I would really appreciate your suggestions.

特别是我更喜欢用 Java 创建(但不摇摆,因为我正在创建网络项目)但我也可以通过 JavaScript 或其他一些有用的库使用.

Especially I am more prefer creating with Java (but not swing because I am creating web project) but I can also used by JavaScript or some other useful libs.

推荐答案

如果您想自定义在浏览器中下载文件的方式,则无法通过标准浏览器功能 (HTML/CSS/Javascript) 来完成.

If you want to customize the way a file is downloaded in a browser, that CANNOT be done via standard browser functionality (HTML/CSS/Javascript).

>

根据响应中发送的 Content-Disposition HTTP 标头的值,浏览器将在文件下载时执行以下两种操作之一:

The browser depending on the value of the Content-Disposition HTTP header sent in the response will either do one of two things upon file download:

  • 尝试根据扩展名解析文件,如果文件是 HTML 则呈现文件,如果是 xml 则显示文件等
  • 如果 Content-Disposition 设置为 attachment,它将打开一个非常基本的弹出窗口,询问保存文件的位置,弹出窗口无法进行控制或自定义.
  • Try to parse the file depending on it's extension, render the file if it's HTML, display it if's xml etc
  • If Content-Dispositionis set to attachment, it will open a very basic popup asking where to save the file, there is no control or customization possible for the popup.

如果您想要比浏览器更多的功能,那么您需要一个小程序(或用户必须安装的其他插件).

If you want more functionality than that in a browser, then you need an applet (or some other plugin the user would have to install).

但由于去年大部分时间浏览器中 Java 的安全问题,现在浏览器不愿意运行小程序,并且即使用户已经安装了 Java,他们也会要求许多用户确认.

But due to security problems for Java in the browser for a large part of last year, these days browsers are reluctant to run applets and they ask for many user confirmations, even if the user already has Java installed.

如果网站用户必须下载 Java 并单击多个弹出窗口才能使文件下载小部件工作,他们可能会离开该网站.

If the users of the site have to download Java and click several popups in order for the file download widget to work, they will probably navigate away from the site.

小程序是当今最好避免的过时技术,因此在 Web 浏览器中,用于保存文件的基本弹出窗口是目前最实用的解决方案.

Applets are these days obsolete technology that is best avoided, so in a web browser the basic popup to save files is currently the most practical solution.

这篇关于文件目的地选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆