I'm using AngularJS for my project and there is PDF downloading process using HTML5 Download and its working fine, and all documents download to default download folder in PC.
Is there any way to download file to select specific folder in local and download it, using JavaScript or Angular?
Asked
Active
Viewed 421 times
-3

Roko C. Buljan
- 196,159
- 39
- 305
- 313

Mahesh Sanjeewa
- 217
- 2
- 11
-
3No, you can't choose the folder. It would be a security risk if you would. – Asons Feb 09 '19 at 15:17
-
1*file* like... a virus for example? – Roko C. Buljan Feb 09 '19 at 15:17
-
@RokoC.Buljan as long as that "file" is not executable and, if it is, nobody executes it, downloading a "virus" is not really a problem – messerbill Feb 09 '19 at 15:19
-
@messerbill like a PDF or PNG for example? – Roko C. Buljan Feb 09 '19 at 15:20
-
@RokoC.Buljan like images, doc, xls, html, PDF......even .exe, .jar, .bin ..... if you do not run it intentionally the potential virus cant do anything – messerbill Feb 09 '19 at 15:22
-
1@messerbill A virus can be hidden in many more file types than an executable one. – Asons Feb 09 '19 at 15:23
-
@LGSon but it still has to be executed.... – messerbill Feb 09 '19 at 15:23
-
@messerbill You are missing the point here. Just being able to put it in someone's local folder of your own choice is a huge security risk. – Asons Feb 09 '19 at 15:25
-
1@messerbill if you *can* download a *file* that masquerades as a regular file - and if you *could* (as the question implies) *automagically* target a specific *local* point - yes it can execute without you even noticing. – Roko C. Buljan Feb 09 '19 at 15:26
-
No. See e.g. here: https://stackoverflow.com/questions/4453798/specify-default-download-folder-possibly-with-javascript – nologin Feb 09 '19 at 15:27
-
@RokoC.Buljan yes i wanted to write the same...but i guess changing files in OS directories is only possible with administrator rights. I only could imagine of manipulating files of third party applications – messerbill Feb 09 '19 at 15:28
-
on the other hand i can not find a single reason why somebody wants a web application to save files to the local system on specific paths except including malware.... – messerbill Feb 09 '19 at 15:31
-
@MaheshSanjeewa what is your desired feature? Maybe there are better solutions – messerbill Feb 09 '19 at 15:31
-
1Exactly. Using JS, HTML, and the `download` property, the user (depending on it's permissions) *must* chose a local download path. So there's always the user to blame :) – Roko C. Buljan Feb 09 '19 at 15:31
-
@messerbill Before download files i want to select path to download files. – Mahesh Sanjeewa Feb 09 '19 at 15:35
-
1@MaheshSanjeewa in such case you're one Google away from your solution. – Roko C. Buljan Feb 09 '19 at 15:38
-
@messerbill The issue is my client need to do that from app without selecting download path from browser – Mahesh Sanjeewa Feb 09 '19 at 15:38
-
@MaheshSanjeewa if you already have an app running on the client's OS you can easily ask the user for permissions to save downloaded files to a specific location – messerbill Feb 09 '19 at 15:39
-
@messerbill Its not running on client.s OS its a web app – Mahesh Sanjeewa Feb 09 '19 at 15:41
-
1@MaheshSanjeewa it really sounds like you want to do something dubious due to you cannot really explain your problem....at this point your answer is: No. Files cannot be saved to a specific folder on the local system of the user using JavaScript. Should be closed. – messerbill Feb 09 '19 at 15:42
-
@MaheshSanjeewa mobile apps are no different. But you *could* *automagically* download to an APP-specific sandboxed and dedicated memory... (depending on grants, OS etc) – Roko C. Buljan Feb 09 '19 at 15:43
1 Answers
0
You can't do that in any major browser (Chrome, Firefox, Edge etc). Only locally installed app can communicat with local file system. There are several options. For example, checkout Electron js project. Using Electorn, you can communicate with host file system using JavaScript or Angular, but again, you have to install Electron to each client.
Another option is a browser extentions with some desktop app which communicate with extention. There are some related questoins here

Pavel Evdokimov
- 28
- 5
-
That would need for the user to install an app made with Electron, which is not the case here. Electron can not by itself (w/o being installed locally) communicate with a local file system through script – Asons Feb 09 '19 at 15:54
-
@LGSon, true - Electron should be installed as an app to the client and this is only option. Why you think this is not an option for this case? – Pavel Evdokimov Feb 09 '19 at 16:01
-
Because if the OP had an app installed it would be told in the question. Now they speak about a HTML5 project using Angular/javascript, which runs in a web browser, hence not an option to ask users to download and install an app for the soul purpose to download a file. Doing that would again be a huge security risk. – Asons Feb 09 '19 at 16:08
-
-
1IMHO, yes, it gives the impression that using Electron one can. If it were reworded, and well explained that with a locally installed app one can chose in which folder to save a downloaded file, but that on the other hand is a completely different use case, where there is a lot more ways to accomplish that with a lot other products than Electron. – Asons Feb 09 '19 at 16:16
-
@LGSon, thanks. I've add some extra explanation based on your comments. – Pavel Evdokimov Feb 09 '19 at 16:25