Transform your ESP32 into a powerful file server with secure web and FTP access. Complete with user authentication, file uploads, downloads, and management capabilities.
Fast, secure, and versatile file management for IoT projects.
Stop struggling with moving files to your ESP32 projects.
This server brings modern web and FTP access to your microcontroller,
making file management as simple as using a cloud service.
With built-in user authentication, responsive design, and intuitive interface,
managing your device's file system has never been easier.
Multi-user support with admin and regular user roles. Session management with automatic timeouts.
Modern web interface plus traditional FTP access. Choose what works best for your workflow.
Connect to your WiFi network or use Access Point mode when no network is available.
Upload, download, create directories and delete files with an intuitive interface and progress tracking.
Admin panel for creating, editing, and deleting users. Control access to your files with fine-grained permissions.
Access your files from any device - desktop, tablet, or smartphone with a beautiful, adaptive interface.
ESP32 + Web Server + FTP + SD Card =
Your Complete File Management Solution
Download the code, flash your ESP32, and start managing your files with ease.
Connect your SD card module to ESP32 using these default pins:
SD Card Pin | ESP32 Pin |
---|---|
CS (Chip Select) | GPIO 5 |
MOSI (Master Out Slave In) | GPIO 23 |
MISO (Master In Slave Out) | GPIO 19 |
SCK (Serial Clock) | GPIO 18 |
VCC | 3.3V |
GND | GND |
Note: You can modify these pin assignments in the code if needed for your specific hardware setup.
// SD card configuration #define SD_CS 5 // SD card chip select pin #define SPI_MOSI 23 #define SPI_MISO 19 #define SPI_SCK 18 // Initialize SD card SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI, SD_CS); SD.begin(SD_CS);
When starting up, the ESP32 will try to connect to your WiFi network using the credentials in the code. If the connection is successful, you can access the server via the IP address shown in the Serial Monitor.
// WiFi credentials const char* ssid = "YOUR_WIFI_SSID"; const char* password = "YOUR_WIFI_PASSWORD";
If WiFi connection fails, the ESP32 will automatically switch to Access Point mode, creating its own WiFi network that you can connect to directly.
// Access Point settings (used if WiFi connection fails) const char* ap_ssid = "ESP32-FileServer"; const char* ap_password = "fileserver123";
Secure login with session management
Intuitive file management interface
// Function to connect to WiFi with multiple attempts
bool connectToWiFi() {
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi...");
// Wait for connection with extended timeout and multiple attempts
int attempts = 0;
const int maxAttempts = 3;
while (attempts < maxAttempts) {
unsigned long startTime = millis();
// Try for 30 seconds per attempt
while (WiFi.status() != WL_CONNECTED && millis() - startTime < 30000) {
delay(500);
Serial.print(".");
}
if (WiFi.status() == WL_CONNECTED) {
Serial.println("\nConnected to WiFi!");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
server_ip = WiFi.localIP().toString();
wifiConnected = true;
accessPointMode = false;
// Start mDNS responder
if (MDNS.begin("esp32files")) {
Serial.println("mDNS responder started - You can access the server at http://esp32files.local");
MDNS.addService("http", "tcp", webServerPort);
} else {
Serial.println("Error starting mDNS responder!");
}
return true;
} else {
attempts++;
Serial.println("\nWiFi connection attempt " + String(attempts) + " failed.");
if (attempts < maxAttempts) {
Serial.println("Retrying...");
WiFi.disconnect();
delay(1000);
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi...");
}
}
}
Serial.println("\nWiFi connection failed after " + String(maxAttempts) + " attempts. Starting Access Point...");
setupAccessPoint();
return false;
}
// Function to set up an Access Point if WiFi connection fails
void setupAccessPoint() {
WiFi.disconnect();
delay(1000);
WiFi.mode(WIFI_AP);
WiFi.softAP(ap_ssid, ap_password);
server_ip = WiFi.softAPIP().toString();
Serial.print("Access Point Started. IP Address: ");
Serial.println(server_ip);
wifiConnected = false; // Not connected to external WiFi
accessPointMode = true; // In AP mode
}
Secure token-based authentication with configurable session timeouts. Automatically expires inactive sessions for better security.
Intelligent network handling that switches to AP mode when WiFi connection fails, ensuring you always have access to your files.
Built-in user roles with regular users and administrators.
Complete set of file management functions including recursive directory creation and deletion, safe file transfers, and more.
The ESP32 File Server is a simple tool that allows you to store and retrieve files from an SD card via a web interface.
No flashing, no auto-updates just basic file management..
.json
or .txt
for your IoT projectsSimple. Reliable. Just a file server. Perfect for lightweight file management on your ESP32 projects.
This project is open-source and free to use. If you find it useful for your projects, please consider supporting its continued development.
(A tiny thanks powers the next evolution.)