Browser-based FTP Client in JavaScript

I’m trying to create a web-based FTP client using JavaScript. My goal is to build something similar to FileZilla that runs in the browser. I have an FTP server set up on port 21 in my network, and I want users to access it through a webpage.

I’ve looked for JavaScript libraries to help with this, but most of what I found is for Node.js, which is backend. I need a frontend solution. I understand JavaScript has limitations when it comes to opening ports, so I’ve configured my FTP server in passive mode to work around this.

Has anyone successfully implemented a browser-based FTP client? Are there any frontend JavaScript libraries or approaches you’d recommend for this task? I’m open to any suggestions or examples that could point me in the right direction.

Here’s a basic structure I’m considering:

class BrowserFTPClient {
  constructor(host, port) {
    this.host = host;
    this.port = port;
  }

  connect() {
    // Implementation needed
  }

  listFiles() {
    // Implementation needed
  }

  uploadFile(file) {
    // Implementation needed
  }

  downloadFile(filename) {
    // Implementation needed
  }
}

// Usage
const ftpClient = new BrowserFTPClient('ftp.example.com', 21);
ftpClient.connect();

Any thoughts on how to flesh this out or alternative approaches?

ooh, interesting project! have u considered using WebDAV instead of FTP? it works over HTTP, which browsers handle natively. might be easieR to implement. plus, it supports more features like file locking and versioning. what do you think about that approach? could it work for ur needs?

hey Leo, browser-based ftp clients are tricky. tried websockets? they offer real-time comm between browser and server. setting up a websocket proxy for your ftp server might bypass port issues. it could work!

Creating a browser-based FTP client is indeed challenging due to browser security restrictions. While WebSockets are a potential solution, they still require server-side implementation. For a purely frontend approach, you might consider using the Fetch API to communicate with a server-side proxy. This proxy would handle the actual FTP operations and expose them through a RESTful interface. Your JavaScript client could then make HTTP requests to this proxy, effectively abstracting the FTP operations. This approach maintains security while allowing you to build a user-friendly interface similar to FileZilla. Remember to implement proper authentication and encryption to protect user credentials and data during transit.