2

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?

kosta
  • 4,302
  • 10
  • 50
  • 104
  • 1
    No, you cannot know where the user puts a downloaded file on their machine. – CollinD Feb 13 '17 at 02:53
  • 1
    Even if it were possible, why does it matter? What would you do with that information? – nnnnnn Feb 13 '17 at 03:05
  • To open a .xlsx file on windows, it needs the character limit of the entire path to be lesser than 219. I would trim the name so that it is exactly 218. – kosta Feb 13 '17 at 03:52
  • How would you trim the name of a file at user filesystem? Why do you not simply notify user of the character limit to open the file? – guest271314 Feb 13 '17 at 03:55
  • I would trim only the filename (not the entire path) before the download. I did not want the user to take care of limiting characters, but if there is no option I will do this. – kosta Feb 13 '17 at 04:14
  • 3
    Does this answer your question? [Get browser download path with javascript](https://stackoverflow.com/questions/9840923/get-browser-download-path-with-javascript) – HaveSpacesuit Jul 22 '20 at 20:57

1 Answers1

2

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

Community
  • 1
  • 1
guest271314
  • 1
  • 15
  • 104
  • 177