This question already has answers here:
Get browser download path with javascript
(4 answers)
Closed 2 years ago.
I am using Java Spring as the backend and plain JS on the front-end.
User can download files from one of the pages on my application.
I want to know the path where the file will be downloaded and saved.
Is it possible to do that?
User can download files from one of the pages on my application. I
want to know the path where the file will be downloaded and saved.
Is it possible to do that?
No.
It is not possible to get the file path which user selects to download file to programmatically. It is not a trivial matter to determine if user downloads file at all. Getting the file path of the downloaded file, if user downloads file, should require user action.
It is not clear from Question why path to downloaded file at user filesystem would be useful or necessary for an application.
An exception, which could be considered a bug Full path to file at local filesystem is set as value of textarea element when files are dragged and dropped at element; would be, at some browsers, where the file or folder path is mistakenly, or unknowingly exposed; for example, by dropping file or folder at a <textarea> element. Though that case still would not verify that the same file which was downloaded would be exposed as a file path at user filesystem. User could change the name of the file at any time, both prior to download at Save File dialog, and after file is saved at user filesystem.
Another exception, at chromium, chrome browsers, would be where file or folder is written to LocalFileSystem.
See
Detect when user accepts to download a file
How FileReader.readAsText in HTML5 File API works?
jQuery File Upload Plugin: Is possible to preserve the structure of uploaded folders?
Related
I have a web application that receives a simple text file, but I need this file to be downloaded to a specific path. Meaning, when the application receives a text file, it will always be downloaded to a specific folder (for example, to C:\MyFolder). If it isn't possible, then I need to copy the file from where user has chosen to my folder.
This application is based on JavaScript.
JavaScript cannot exert any control over my (the visitor's) local filesystem. I remain in complete control of where my downloaded files go, what they are named, and indeed whether I even want to download them in the first place.
Sorry, but the best you can do is inform your users where to put the file you're offering for download. You cannot use JavaScript to choose the destination yourself.
You should be able to do this using a Java applet assuming that you have signed it. The user would be asked to allow your code to run and if allowed, you could do whatever you want: Including downloading a file to a specific location.
I have a web application that receives a simple text file, but I need this file to be downloaded to a specific path. Meaning, when the application receives a text file, it will always be downloaded to a specific folder (for example, to C:\MyFolder). If it isn't possible, then I need to copy the file from where user has chosen to my folder.
This application is based on JavaScript.
JavaScript cannot exert any control over my (the visitor's) local filesystem. I remain in complete control of where my downloaded files go, what they are named, and indeed whether I even want to download them in the first place.
Sorry, but the best you can do is inform your users where to put the file you're offering for download. You cannot use JavaScript to choose the destination yourself.
You should be able to do this using a Java applet assuming that you have signed it. The user would be asked to allow your code to run and if allowed, you could do whatever you want: Including downloading a file to a specific location.
I am able to use the HTML5 Download attribute to specify a file for download to the user's declared downloads folder, but what I would like to do is allow for users to create a "portal" that specifies a directory that future files can be downloaded to.
The wording is confusing so I'll use an example:
User will be using the site to exchange source code with a coworker. However, whenever the using downloads his coworker's source code, it always defaults to his Browser designated "downloads" folder. Is it possible to have the User be able to specify on the website that he wants it downloaded to a specific directory? Namely, his workspace for whatever project he is collaborating on.
Hopefully, this is descriptive enough. I really can't find any tools for this online.
Its not possible as the download location is controller by the browser.
If you want to know more give the page a read Download A File At Different Location Using HTML5
I have a web application, I have a requirement to download more than 10 files to a folder. By default the download happens to browser download location. The user have a new requirement to have an option to select the folder where there need to save the file from web application. Could you please let me know whether it is possible in all browsers, I know by default chrome starts downloading to download folder. The user will be searching with some condition and all files which match the condition should be downloaded to the folder given by user.
Could you please let me know whether I can override the download location in browser like chrome.
Is it possible to manipulate a file only with client side programming? I am creating a text editor, which takes an uploaded file and need to save to another location after editing. Is it possible with client side coding?
Yes, everything you described is possible. Things you need are: the FileReader API for reading the files and download attribute of a for saving the with specific name. The solution won't be cross-browser but it'll work in the modern browsers.
Edit 1: You can't to the manipulation like in language which have full access to the file system (i.e. you can't open files by their path for example). The user needs to drag the text file in the page which is your editor or select the file with <input type="file" />.
Edit 2: The same is for saving the file. You can give the user a link with specified file name in the download attribute. When the user press this link the file will be saved in his download folder.