Reputation: 1944
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 don't want to set the path myself i just wanna know where my file goes after been downloaded by the user.
Upvotes: 23
Views: 70964
Reputation: 2300
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;"/>
Upvotes: 1
Reputation: 1162
https://www.npmjs.com/package/downloads-folder
Usage
const downloadsFolder = require('downloads-folder');
console.log(downloadsFolder());
Installation
$ npm install downloads-folder
Upvotes: 2
Reputation: 114347
Browsers are deliberately isolated from the local filesystem in order to prevent scripting attacks. You cannot get this information.
Upvotes: 13
Reputation: 348972
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\
.
Upvotes: 33