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.
Related
Consider the following case:
In my webpage, I have two links that are used for downloading two distinct files, one for a.css and one for a.js.
CLIENT_AAA prefers to download the a.css file into /path/to/css/ folder and a.js file to /path/to/js/ folder in his specific computer. CLIENT_BBB will probably use different folders, but it's out of our scope.
Problem is that when this user saves a.js and then downloads a.css, the browser (Chromium in my case) suggests downloading the new file to /path/to/js/ folder because that was the last folder used for a download. User needs to click up, select css folder and then save the file.
I wonder if I can "suggest" the browser for a valid download folder for that user per link, so when user clicks <a href="a.css" download>a.css</a>, browser will open /path/to/css folder and when user clicks <a href="a.js" download>a.js</a>, it will open /path/to/js folder. Is that possible?
That's totally up to the browser. There's no HTTP header to do what you're asking. You can specify the filename in Content-Disposition but that's all.
Consider that if you could nudge the browser towards a particular path, and browsers followed your suggestion, that would let bad people create downloads that overwrite system files with whatever content they want. Of course, people can still do that to themselves, but letting the server direct the browser to a particular full path would be a severe security problem.
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
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?
I am trying o make app for my work (will be used only in my office) and among other things I need way to download file (it will be always one ODT and one txt document which will be initiated by clicking on button by user, on specific page - standard download) from our local server. Those two files are created on server and then sent to download to user which requested it, so that part is simple as any other web page which offers you download.
But after download is finished I need somehow:
1) automatically open ODT (openOffice writer) file, so user can continue editing it. What will happen next is not important...
2) automatically move TXT file to specific folder on users disk (this is needed because that specific folder is monitored by our special printer and whenever printer detects file in that folder it automatically starts printing). Setting default chrome download folder as that monitored folder is not options - so I NEED to move TXT file automatically after download to that monitored folder.
3) After first two actions are finished I need to clean default download folder (foldere where chrome downloads by default) because it would be full of those files and they are not needed anymore.
Now, it would be great if I could accomplish it just with javascript but as I know there is no way to manipulate files on local system without displaying dialog to user - so this is not option.
I figure it out that this part could be done by chrome extension, which is acceptable solution because this application will be used only in my office. But I am not sure how and if it is really possible to accomplish what I want so I need your help.
P.S.
It is important that after user click "Download" on page to download ODT and TXT file, there is no other windows, dialog and other "questions" by browser but everything after that should go automatically.
Thank you!
Yes, you can do those tasks with chrome.downloads API, as long as you can accept a subfolder of the Downloads folder as a target for your printer. You cannot download in an arbitrary folder, I'm afraid.
After a download you initiated with chrome.downloads.download finishes, you can initiate opening it with chrome.downloads.open(downloadId).
You can initiate a download into a subfolder by supplying a relative path to chrome.downloads.download (note the / slash instead of \): printout/file.txt.
You can remember the download id's and clean up afterwards with chrome.downloads.removeFile(downloadId).
Please take note of the permissions you need to add, they are quite fine-grained for this API.
I have an embedded system with a web server Mongoose, I have to allow the client to download some log files generated at runtime, I have a problem during the download, in practice, the browser first downloads the file and then asks where to save the file .
The behavior is unpleasant because the download takes a few seconds and the client does not understand what's going on.
Is there any option, for example, in the header of the file, to force the browser to ask before making the download where to save the file?
Thanks.
it is not up to you to decide how the client's browser is behaving.
if the browser is set to save the file automatically in a specific place, then there is nothing you can do.
your only workarounds is to either upload your file somewhere and suggest the viewer to right-click a download link that points to the file, it will open the dialog,
or suggest the viewer to change browser settings,
or write a browser extension that does that and offer viewers to install it.