V
V
vlad49902020-03-31 19:53:22
css
vlad4990, 2020-03-31 19:53:22

How to download an .htm file from a server using JavaScript using the FTP protocol?

There is a task to make a standalone Widget / Informer for displaying weather data, which will be embedded on third-party sites through the "iframe" tag.
As weather data, there is a file on the server, access to which is via the FTP protocol.
You need to download this file via ftp using Javascript.
As a possible solution, I found XMLHttpRequest, the official site states that this API has support for FTP Requests, but I did not manage to download the file using it.
Here is the sample code I used:

const xhr = new XMLHttpRequest();
xhr.open('GET', 'ftp://SITE.COM/PATH/FILE.htm', false, 'LOGIN, 'PASSWORD');
xhr.send();

Here is what the browser console outputs:
5e836efcd202e098483203.png
If you simply enter this request into the browser drain (After entering the login and password through the ":" symbol - ftp://LOGIN:[email protected]/PATH/FILE.htm ), then the automatic download of this file by the browser starts.
I do not have access to the server, except for separate folders with weather data via FTP protocol.
How to correctly generate FTP requests in this API, or are there some simpler and more reliable ways to download this file via FTP?
My knowledge in web development leaves much to be desired.
Thank you in advance for any response, advice or guidance!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Roma Zvarich, 2019-09-18
@sasha_jarvi

How to make a background like this?

Can be done with two layers property background
https://codepen.io/hisbvdis/pen/oNvaGqg

P
profesor08, 2020-03-31
@profesor08

Nothing from the browser. The browser does not provide an API for working with FTP.

S
Sergey Romanov, 2020-03-31
@Serhioromano

The name of the XMLHttpRequest function shows that this is an HTTP request and not an FTP request. Although some documentation, such as Mozilla, mentions that it is possible to connect to FTP, in reality, no browser supports this specification at the JavaScript executor level.
In other words, the answer to your question is no way.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question