简体   繁体   English

直接保存文件到指定路径,不显示保存或打开对话框

[英]Save file directly to specified path without showing save or open dialogue

I'm invoking javascript in a web page using我在网页中调用 javascript 使用

webBrowser2.Document.InvokeScript("download_file");`. 

This javascript opens dialogue asking user to save or open the file.此 javascript 打开对话框,要求用户保存或打开文件。 I want to save the file directly to the path without showing the dialogue to user.我想将文件直接保存到路径而不向用户显示对话。 How can i achieve this.我怎样才能做到这一点。 I'm scraping the web page.我正在抓取网页。 I'm extracting the required details from the web page.我正在从网页中提取所需的详细信息。

download_file() :下载文件()

function download_file() {
    var summaryFlag = 0;
    if (document.getElementById("frmincludefilesummary").checked) {
        summaryFlag = 1;
    }
    url = '/filedatabase/file_process_request.html?mru=53616c7&type=doc';
    url += '&sum=' + summaryFlag + '&logo=0&xcode=name&serve_txt=0&folderid=';
    document.location = url;
}​

The thing you are trying to achieve is not possible.你想要达到的目标是不可能的。 Javascript cannot access or write to the client filesystem directly. Javascript 无法直接访问或写入客户端文件系统。 If allowed it would be a huge security breach.如果允许,这将是一个巨大的安全漏洞。

Alternate options would be to make use of flash or java or activeX.备选方案是使用 flash 或 java 或 activeX。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM