“另存为"在 Web 浏览器上下载文件时的对话框 [英] "Save As" Dialog box when downloading a file on web browser

查看:48
本文介绍了“另存为"在 Web 浏览器上下载文件时的对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要打开一个另存为"对话框,用户可以在其中单击浏览器中的链接.另存为对话框需要显示客户端系统文件夹结构(类似于word、excel等的另存为对话框)

I need to open an "Save As" dialog box where the user clicks on a link in the browser. The save as dialog needs to display the client system folder structure (Dialog similar to save as in word, excel, etc)

我确实提到了一些与之相关的类似问题.但通常下载的文件会保存在客户端设置的下载路径中.

I did refer some similar question related to it. But often the downloaded file gets save in the Download path set by the client.

我不想使用 ActiveX 控件并希望使用 Javascript 来做同样的事情

I don't want to use ActiveX control and looking to do the same using Javascript

是否可以使用 javascript 打开另存为"对话框并将下载文件保存到本地客户端系统中的特定路径.?

Is it possible to open a "Save as" dialog using javascript and save the download file to that specific path in the local client system.?

如果这是不可能的,大部分文章都指出了这一点.他们表示,由于安全原因,这是不可能的.但是他们没有明确指出原因(这样做会带来什么安全问题,是否限制浏览器不执行此类操作等,)

If this is not possible, which most of the article has pointed out. They state that its not possible due to security. But they don't clearly point the reason (what is the security problem that would arise by doing so, If there is a restriction to browsers to not perform such operation etc.,)

推荐答案

是否可以使用 javascript 打开另存为"对话框并将下载文件保存到本地客户端系统中的特定路径.?

Is it possible to open a "Save as" dialog using javascript and save the download file to that specific path in the local client system.?

没有.您可以建议浏览器打开对话框,但不能告诉它默认打开的位置.

No. You can suggest to the browser that it open the dialog, but you cannot tell it where to default to.

如果这是不可能的,大部分文章都指出了这一点.他们表示,由于安全原因,这是不可能的.但是他们没有明确指出原因......

If this is not possible, which most of the article has pointed out. They state that its not possible due to security. But they don't clearly point the reason...

因为人们在点击之前不会阅读内容.因此,如果我给您一个文件链接并希望将它放在您的驱动器上 C:\Windows\System32\blahblah 并且我将其设置为文件保存对话框中的默认值,可悲的是有百分比的人会盲目地点击保存"而不考虑其含义.现代操作系统(和旧的 *nix 操作系统)试图通过将某些操作赋予特权来保护用户免受自身侵害,但至少在 Windows 上,这通常只是另一个是/否弹出窗口,用户经常不假思索地说是".

Because people don't read things before they click them. So if I give you a link to a file and want to put is on your drive at C:\Windows\System32\blahblah and I set that as the default in the file save dialog, sadly a significant percentage of people are going to just blindly click Save without thinking through the implications. Modern operating systems (and old *nix ones) try to protect users from themselves by making certain operations privileged, but still, at least on Windows that's usually just another Yes/No popup users frequently say Yes to without thinking.

最好是浏览器选择用户的标准文档文件夹,或者他们特意配置的文件夹,而不是让网页说明默认的位置.

So best if the browser picks the user's standard document folder, or one they've specifically, intentionally configured, rather than let the web page say where to default to.

这篇关于“另存为"在 Web 浏览器上下载文件时的对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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