Is it possible to download file from FTP using Javascript?

前端 未结 2 1913
情书的邮戳
情书的邮戳 2020-12-11 08:08

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

相关标签:
2条回答
  • 2020-12-11 08:52

    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';
    
    0 讨论(0)
  • 2020-12-11 08:54

    At the most basic just make a link like this:

    <a href="ftp://...." target="_blank">Download in new tab/window</a>
    

    In JS just open a window with that url.

    0 讨论(0)
提交回复
热议问题