Download file from FTP via Javascript

前端 未结 4 1045
北荒
北荒 2020-12-11 05:13

I have a got a file server and a web server. They are running on physically different machines.

I would like to download a file from the FTP server via JavaScript. T

相关标签:
4条回答
  • 2020-12-11 05:44

    Javascript only speaks HTTP and WebSockets (on newer browsers), and not FTP. In that situation, keeping it all on the client-side, you'd probably have to write a Flash or Java applet that handles the actual FTP protocol, and interface with Javascript to provide interactivity.

    Unless you're planning on redirecting the browser to the ftp site, passing in the username and password? Are you concerned about the users getting the FTP information, or are you concerned with man-in-the-middle attacks sniffing the plaintext FTP credentials?

    0 讨论(0)
  • 2020-12-11 05:45

    How about creating an iframe and setting the url to ftp://whatever?

    0 讨论(0)
  • 2020-12-11 05:49

    If by "downloading" you mean "prompt user to save a file from external link" (which basically means open a new window with URL that points to a file) then you can just point user to a script you have control over.

    window.open('http://myserver/get_file/filename');
    

    And your server-side get_file script will do all the work of connecting to a FTP and fetching a file

    0 讨论(0)
  • 2020-12-11 06:04

    JavaScript doesn't support FTP. What you need is a server-side or a more robust client-side language to access the remote server.

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