Get browser download path with javascript

后端 未结 4 1712
隐瞒了意图╮
隐瞒了意图╮ 2020-11-29 11:07

I searched quite a lot for an answer on the web and found nothing.

Is there a way to get the download path of a browser via Javascript?

I d

相关标签:
4条回答
  • 2020-11-29 11:40

    That is not possible.

    Pure browser-JavaScript is not be able to get information about the user's filesystem. The default download path might also contain sensible information, which is risky:

    Imagine that one stores his downloads at C:\CompanyName\RealName\PhoneNumber\Adress\.

    0 讨论(0)
  • 2020-11-29 11:53

    Browsers are deliberately isolated from the local filesystem in order to prevent scripting attacks. You cannot get this information.

    0 讨论(0)
  • 2020-11-29 11:59

    https://www.npmjs.com/package/downloads-folder

    Usage

    const downloadsFolder = require('downloads-folder');
    
    console.log(downloadsFolder());
    

    Installation

    $ npm install downloads-folder
    
    0 讨论(0)
  • 2020-11-29 12:00

    Maybe wrong answers. You can do it with some IE versions. It is valid in case you use it for intranet web development as development of products/workflow that requires files. It does not work with other browsers (Schrome, Firefox, Safari, AFAIK).

    <input
    type="hidden"
    id="steel_that_path"
    name="steel_that_path" />
    
    
    <input type="file"
    id="this one you use to upload file"
    name="this one you use to upload file"                                              
    accept="application/octet-stream"                                                 
    onBlur="document.getElementById('steal_that_path').value=this.value;"/> 
    
    0 讨论(0)
提交回复
热议问题