DIY Projects

ESP32. Access SPIFFS files in FTP with the ESP8266FtpServer library

esp32 ftp arduino spiffs esp8266ftpserver library

There are several libraries allowing access to the SPIFFS file system stored on the flash memory of an ESP32 in FTP. The ESP8266FtpServer.h library developed by David Paiva (nailbuster on GitHub) very easy to use, allows you to add a small FTP server to the Arduino code of the ESP32 project. It also works on ESP8266. It can be used to retrieve data files or remotely update the HTML interface files, the data file of a data acquisition.


The SPIFFS file system for ESP32 is used to store files on the flash memory module. We can separate the code of the HTML interface (HTML file, CSS style sheet, javascript code) as well as data or parameter files. We will use the SPIFFS.h library to access, create or modify the files from the Arduino code of the project.

Limitations of the SPIFFS File System

Before you begin, remember that the SPIFFS file system is very limited.

Add the ESP8266FtpServer.h library to an ESP8266 project

The ESP8266FtpServer.h library is still under development. It is an adaptation of the Arduino library from Gallegojm. It can do us a lot of service in two situations.

It is not available from the library manager of the Arduino IDE. It will therefore be necessary to manually recover the files and add them to the ESP32 project.

Go to the project’s GitHub page here then download the project code

Unzip the ZIP archive then move the ESP8266FtpServer.cpp and ESP8266FtpServer.h files at the root of the project at the same level as the ino file of the project.

Example of an FTP file server on ESP32

Create a new sketch on the Arduino IDE and paste the following code.

Modify the following parameters:

#ifdef ESP8266
  #include <ESP8266WiFi.h> 
#elif defined ESP32
  #include <WiFi.h>
  #include "SPIFFS.h"
#include "ESP8266FtpServer.h"

const char* ssid = "enter_your_ssid";
const char* password = "enter_your_password";
const char* ftp_user = "esp32";
const char* ftp_password = "esp32";

FtpServer ftpSrv;  
void setup()

  WiFi.begin(ssid, password);

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
  Serial.print("Connected to ");
  Serial.print("IP address: ");

  Serial.println(F("Inizializing FS..."));
  // FTP Setup, ensure SPIFFS is started before try to use ftp methods  
#ifdef ESP32       
  if (SPIFFS.begin(true)) {
#elif defined ESP8266
  if (SPIFFS.begin()) {
    Serial.println("SPIFFS opened!");
    ftpSrv.begin(ftp_user, ftp_password);   //username, password for ftp

void loop() {

How Arduino C++ Code Works

As the library files are at the same level as the ino file, we declare the ESP8266FtpServer.h library between quotes to indicate to the compiler that we must use the local files.

#include "ESP8266FtpServer.h"

We then create the C++ object that will start the FTP server and manage external requests

FtpServer ftpSrv;

When starting the ESP8266, we start the FTP server using the begin() method in the setup(). The begin method of the FtpServer object takes two parameters which allow you to define the login credentials for the FTP server(user, password).

if (SPIFFS.begin()) {
   Serial.println("SPIFFS opened!");
   ftpSrv.begin(ftp_user, ftp_password); // username, password for ftp. Set ports in ESP8266FtpServer.h (default 21, 50009 for PASV)

Finally, the requests to connect to the server handleFTP function are monitored in the loop().

void loop(void){

Other parameters can be configured directly in the library

It’s finished, you can now access your files in FTP.

Accessing SPIFFS using Filezilla

In the current version, only the passive mode is supported. SFTP (Secure FTP) is not supported.

Start FileZilla. The easiest way to connect to an ESP8266 in FTP and use the site manager. I encountered difficulties using the Quick Connect bar. Open the Site Manager from the File menu and configure the access as follows:

Start the connection by clicking on Connection. The connection is now saved by FileZilla, it will not be necessary to do it again.

As the connection is not secure, you must accept the warning before you can connect to the ESP32.

Once the connection is established, you have access to all the files in the Data directory of the Arduino project.

SPIFFS and LittleFS files can also be accessed by FTP on ESP8266.


09/04/2020 First publication of the tutorial

Click to rate this post!
[Total: 1 Average: 4]
Exit mobile version