javascript 如何创建用于下载文件的新文件夹
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22335988/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to Create a New Folder for Downloading a File
提问by hucuhy
I want to download folder that client side (browser) make.
我想下载客户端(浏览器)制作的文件夹。
I considered using File API, but I can't find how to make folder.
我考虑过使用File API,但我找不到如何制作文件夹。
For example, some png make from html canvas put one folder, I want to save this folder with download dialog.
例如,一些来自 html canvas 的 png 将一个文件夹放在一个文件夹中,我想用下载对话框保存这个文件夹。
I want to use a folder for some file to one folder.and I must download only once.
我想将某个文件的文件夹用于一个文件夹。我必须只下载一次。
Please advise me.
请给我提意见。
html
html
<a download='folder' href='#' onclick="Download()">download</a>
回答by kwh
You can use FSO.js, but be warned that it currently only works in Chrome. Additionally, the folders you create can only really be accessed from within your webapp (for example, you can't choose to write a specific folder on the C drive).
您可以使用FSO.js,但请注意它目前仅适用于 Chrome。此外,您创建的文件夹实际上只能从您的 web 应用程序中访问(例如,您不能选择在 C 驱动器上写入特定文件夹)。
回答by MGot90
Firstly, You can't really interact with the local system or the server with JavaScript because of security. You can call a server-side script with JavaScript, via AJAX.
首先,由于安全性,您不能真正与本地系统或服务器与 JavaScript 交互。您可以通过 AJAX 使用 JavaScript 调用服务器端脚本。
If you don't care, you can check out Javascript FSO CreateFolder Method
如果你不在乎,你可以查看Javascript FSO CreateFolder Method
JavaScript Example...
JavaScript 示例...
// initialize ActiveXObject and create an object of Scripting.FileSystemObject.
var fso = new ActiveXObject("Scripting.FileSystemObject");
// creates a folder with specified name at the specified location
fso.CreateFolder("C:\Temp\myFolder");
fso = null;