lightPHPFM - Lightweight Single-File PHP File Manager
A fast, lightweight, and modern single-file PHP file manager with no external dependencies (zero CDN links, no database needed). Designed for quick deployment, local development, VPS administration, or lightweight file sharing.
✨ Features
- Single-File Architecture: Everything (PHP backend, CSS styles, JavaScript, and SVG icons) is self-contained in
index.php. Works 100% offline and in air-gapped environments. - Database-Free Authentication: Secure session-based authorization with CSRF token verification and password hashing (
password_hash/password_verifyor plain-text fallback for quick setup). - Text & Code File Editor:
- In-browser editor for text and code files (
.txt,.php,.html,.css,.js,.json,.md,.py,.sql,.env, etc.). - Gutter with synchronized line numbers.
- Tab key indentation (inserts 4 spaces without losing focus).
- Keyboard shortcuts:
Ctrl+S/Cmd+Sto save,Escto close with unsaved changes confirmation.
- In-browser editor for text and code files (
- Image & Media Preview (Lightbox):
- Responsive lightbox viewer for images (
.jpg,.jpeg,.png,.gif,.webp,.svg,.bmp,.ico). - Zoom in/out, 90° rotation, and image dimension display (
width × height px). - Previous / Next gallery navigation with arrow keys (
←,→).
- Responsive lightbox viewer for images (
- Comprehensive File Operations:
- Create new files and directories.
- Rename items.
- Safe duplicate / clone files and folders.
- Recursive deletion for single or batch-selected files and folders.
- Copy, Cut, and Paste: Multi-item clipboard mechanism preserved across directory navigation.
- Download & ZIP Archiving:
- Direct single-file download.
- Download entire folders or multiple selected items as a ZIP archive created on the fly.
- Extract ZIP archives directly on the server (using PHP's
ZipArchive).
- Drag & Drop & Advanced Uploads:
- Drag & drop files or folders directly into the browser window.
- Recursive folder uploading preserving nested folder structures (via HTML5
webkitGetAsEntryandwebkitdirectory). - Floating upload widget with real-time progress bar, percentage, and uploaded byte counts.
- Modern UI & UX:
- Dark mode by default with instant toggle to Light mode (saved in
localStorage). - Breadcrumb navigation with clickable directory segments.
- Instant live search and filter bar.
- Column sorting by Name, Size, Permissions, and Last Modified date.
- Server storage space indicator (Free space, Total space, and Usage bar).
- Dark mode by default with instant toggle to Light mode (saved in
- Security & Hardening:
- Path traversal protection (canonical path checking against configured root directory).
- CSRF token validation on all state-changing requests.
- Self-protection:
index.phpis protected against accidental rename, deletion, or overwrite.
🚀 Quick Start
1. Requirements
- PHP 7.4 or PHP 8.x
- Optional:
php-zipextension for ZIP archive download and extraction. - Optional:
php-fileinfofor enhanced MIME type detection.
2. Run with PHP's Built-in Server
Place index.php in your desired directory and run:
php -S localhost:8000 index.php
Open your browser and navigate to http://localhost:8000.
3. Default Login Credentials
- Username:
admin - Password:
admin
⚙️ Configuration
lightPHPFM can be configured in two ways:
- External Config File (
config.php): Copyconfig.sample.phptoconfig.phpin the same directory. Any settings inconfig.phpoverride internal defaults without touchingindex.php. - Internal Settings (
index.php): If noconfig.phpfile exists,index.phpuses its built-in internal settings.
1. Selecting the Root Folder
You can specify where the root folder is located:
Option A: Single Root Directory
Set an absolute path or relative path to any folder on your server:
// In config.php or index.php:
'root_dir' => __DIR__ . '/uploads', // Browse inside the "uploads" subfolder
// 'root_dir' => '/var/www/html/storage',// Absolute Linux path
// 'root_dir' => 'D:/MyStorage', // Windows path
Option B: Multiple Selectable Root Folders
You can define multiple root folders. When configured, an interactive Root selector dropdown appears in the top navigation bar, allowing users to switch between root directories on the fly:
'root_dirs' => [
'Main Project' => __DIR__,
'Uploads' => __DIR__ . '/uploads',
'Logs' => '/var/log',
],
2. Read-Only Access Mode
You can configure read-only mode either globally for everyone, or on a per-user basis:
Global Read-Only Access
Disables upload, create, edit, rename, and delete for all visitors. The UI switches to viewer mode and shows a [READ-ONLY] badge:
'read_only' => true,
Per-User Read-Only Access
Grant full write access to administrators while restricting guest/viewer accounts to read-only access:
'users' => [
// Full write access
'admin' => 'admin',
// Read-only user
'viewer' => [
'password' => 'guest123',
'read_only' => true,
],
],
3. Full Configuration Reference
return [
'auth_enabled' => true,
'users' => [
'admin' => 'admin',
],
'root_dir' => __DIR__,
// 'root_dirs' => ['Site' => __DIR__, 'Uploads' => __DIR__ . '/uploads'],
'read_only' => false,
'hide_hidden_files' => true,
'max_upload_size' => 128 * 1024 * 1024,
'datetime_format' => 'Y-m-d H:i:s',
];
Generating a New Password Hash
To generate a secure bcrypt password hash in PHP:
php -r "echo password_hash('your_new_password', PASSWORD_DEFAULT) . PHP_EOL;"
Copy the generated hash into $CONFIG['users']['username'].
🌐 Web Server Deployment
Apache
Ensure AllowOverride All is enabled and mod_rewrite is active if needed. No special configuration is required; simply place index.php in your DocumentRoot or a subfolder.
To increase upload file size limits in .htaccess:
php_value upload_max_filesize 128M
php_value post_max_size 128M
php_value max_execution_time 300
php_value max_input_time 300
Nginx
Example virtual host configuration:
server {
listen 80;
server_name files.example.com;
root /var/www/lightphpfm;
index index.php;
client_max_body_size 128M;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
🔒 Security Best Practices
- Change the Default Password: Immediately update the
adminpassword before exposinglightPHPFMto any network or public internet. - Use HTTPS: Always serve the file manager over SSL/TLS (HTTPS) to protect session cookies and authentication credentials in transit.
- Restrict Access by IP: In production environments, consider restricting access to trusted IP addresses via web server rules or VPN.
- PHP Upload Limits: Adjust
upload_max_filesizeandpost_max_sizeinphp.inito match your intended file upload requirements.
📄 License
MIT License. Free for personal and commercial use.