i am currently having trouble with creating an option for user to let him/her choose where they want to save files locally after clicking download button. all this is done for a chrome extension that places a button in a specific website and downloads files from that page. I am able to make it work for a folder i create on my own but don't know how to let users choose where they want to save files.
我目前无法为用户创建一个选项,让他/她在点击下载按钮后选择他们想要在本地保存文件的位置。所有这些都是针对Chrome扩展程序完成的,该扩展程序将按钮放在特定网站中并从该页面下载文件。我能够使它适用于我自己创建的文件夹,但不知道如何让用户选择他们想要保存文件的位置。
here is my code:
这是我的代码:
chrome.downloads.onDeterminingFilename.addListener(function(item, suggest) {
if (getLocation(item.url).hostname == "balle.ac.in" || getLocation(item.url).hostname == "37.221.102.132")
{
suggest({filename: "Downloads"+ "/" + subject_name + "/" + teacher_name + "/" + item.filename.split("_").slice(4).join("_")});
console.log(getLocation(item.url).hostname);
}
});
1 个解决方案
#1
0
chrome.downloads.onDeterminingFilename
is too late to show Save As dialog, since you "places a button in a specific website and downloads files from that page", you could use chrome.downloads.download instead.
chrome.downloads.onDeterminingFilename为时已晚,无法显示“另存为”对话框,因为您“将按钮放在特定网站中并从该页面下载文件”,您可以使用chrome.downloads.download。
If both filename and saveAs are specified, then the Save As dialog will be displayed, pre-populated with the specified filename.
如果同时指定了filename和saveAs,则将显示“另存为”对话框,并使用指定的文件名进行预填充。
#1
0
chrome.downloads.onDeterminingFilename
is too late to show Save As dialog, since you "places a button in a specific website and downloads files from that page", you could use chrome.downloads.download instead.
chrome.downloads.onDeterminingFilename为时已晚,无法显示“另存为”对话框,因为您“将按钮放在特定网站中并从该页面下载文件”,您可以使用chrome.downloads.download。
If both filename and saveAs are specified, then the Save As dialog will be displayed, pre-populated with the specified filename.
如果同时指定了filename和saveAs,则将显示“另存为”对话框,并使用指定的文件名进行预填充。