Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to download file from FTP using Javascript?

Suppose, I've a FTP URL (ftp://xyz.org/file.zip). If I type this in the browser manually, then hit enter, the browser will start to download the file.zip and would ask me save it on harddisk.

My question is: Is it possible to write a script in JavaScript, which when run should download the file with all these options (separately)?

  • in a new window?
  • in a new tab in the same window?
  • without opening a new window or tab?
like image 938
Nawaz Avatar asked Jan 21 '23 05:01

Nawaz


1 Answers

new window or new tab is controlled by the user's preference, and you can't override that. But to open your URL in a new tab/window you would use

window.open('ftp://xyz.org/file.zip');

to request it without opening a new window just

window.location = 'ftp://xyz.org/file.zip';
like image 101
Jamiec Avatar answered Jan 22 '23 18:01

Jamiec