How do I create an FTP protocol?

What is the best example of FTP?

The two most famous examples are the ones by Guillermo Amaro Alonso () and Rob Miles ().

The one by Guillermo has more comments than the example (in Spanish). The problem is that he was a good web developer 15 years ago and the language changes a lot. The example I was working on, for example, doesn't work because the browser's XHR implementation is now async and needs to be done asynchronously.

The other one, by Rob, is a perfect example of code that I hate seeing. He did a great job with it, but I really hate any example of FTP written without a dependency injection container. It's just a pile of code. I've even seen people try to rewrite DI containers into libraries.

Do you know any good, simple, modern example? P.: It's important to know that I'm not looking for a library or tool that does it for me, but something to help in the context of developing.

1 Answer.
There's no good example of FTP. Most FTP implementations don't provide the full feature set required for a good example, such as file transfer completion notifications, progress indications (for the user or the backend) and resumable uploads.

There are also many FTP libraries and servers available today, all targeting a specific use case (ie an HTTP API), for example, the standard HTML5 file upload form in some browsers (file API) and the PHP cURL extension (a standardised interface) being one such example. I think the best example is how the most commonly used file transfer protocol is managed today, which is SMTP. This protocol has a long history (dating back to 1973) and today it's fully implemented in nearly every web and mobile device, with very few exceptions (such as the iPhone where we still need a separate FTP-app).

FTP and other similar protocols have been built over decades, and the only aspect about which you could be correct today is "the language changes a lot", that's why I don't think you should hold your breath waiting for a single good and up-to-date example to come out.

How do I create an FTP protocol?

I would like to create an FTP protocol, as seen on the following picture: So, do you guys have any idea on how I can do that?

I don't know what your aim is with this, but here's some code that will do what you want, using a standard SFTP server. There are similar classes for SFTP, etc. Just make sure you have a FileChannel on the server side which will act as a buffer and will be the input/output channel for all the communication.

How to use FTP server to transfer files?

Hi, I am new to PHP.

I use a cgi script written in PHP to transfer some images between an FTP server and a web server. If I directly enter the IP address of the FTP server in my browser, I am able to login to the FTP server but I can't view or copy any files from the FTP server as I am unable to login in to the FTP server.

So I tried connecting the FTP server with my machine using ftpconnect() function in PHP. But this time when I try to login to the FTP server, I am not able to login to it. It says "Sorry, this account has not been used in a while and cannot be logged in" which is the same error that I get when I directly enter the IP address of the FTP server in my browser.

So I need to use a local FTP server in my PC in order to transfer the files. Can anyone please tell me ? Thanks. Assuming that the FTP server is running on your machine, I'm not sure why you'd use a local FTP server, because you could just as easily connect directly to the FTP server via your browser. The advantage of a local FTP server is that it will always be up and running. Your cgi script should be running on the same server as the FTP server (for instance).

There are two ways to use an FTP server with your cgi script. One is that you read the data from the input stream of the file and write it to the output stream. That will allow you to read the entire file at once into memory.

Related Answers

Is FTP port 22 or 21?

I was wondering if anyone can help me out. I'm on a project to use...

What is an example of file transfer?

I have a file on my computer. I would like to transfer...

What is Axway managed file transfer?

Axway is an industry-leading provider of remote mobile workforce manag...