Cross-Platform PHP File Manager with Database Integration
A comprehensive, single-file PHP web application that functions as a secure online file manager with integrated MySQL database management capabilities. Fully compatible with both Windows Server and Linux distributions including Ubuntu, CentOS, Debian, Fedora, and more.d
Key Highlights:
- π Single File Deployment - Just upload one PHP file and you're ready!
- π¨ Modal Code Editor - Full-screen Monaco editor with keyboard shortcuts
- ποΈ Database Management - Full MySQL administration with enhanced error handling
- π‘οΈ Enterprise Security - CSRF protection, session management, path sanitization
- π± Responsive Design - Professional cPanel-style interface
- π Cross-Platform - Windows Server, Linux distributions, Docker support
- π Unix Permissions - Full Linux file permission display and management
- π² Collapsible Tree - Smart folder navigation with state persistence
- Full-Screen Modal Editor - Edit files in a professional modal overlay
- Collapsible Directory Tree - Folders collapse/expand with smooth animations
- Smart State Persistence - Tree state saved in localStorage
- Expand/Collapse All - Quick buttons to manage all folders at once
- cPanel-Style Design - Modern, professional interface inspired by cPanel
- Gradient Header - Beautiful header with breadcrumb navigation
- Card-Based Operations - File operations in gradient cards with hover effects
- Icon Action Buttons - Compact, intuitive action buttons with tooltips
- Enhanced Color Palette - Professional color scheme with smooth transitions
- Better Error Handling - Detailed error messages for database operations
- Connection Diagnostics - Clear feedback on database connection status
- Keyboard Shortcuts - Ctrl+S to save, ESC to close modal
- Performance Optimizations - Faster loading and smoother interactions
- Web Authentication - Login protection with session management
- File Operations - Upload, download, create, edit, rename, and delete files/folders
- Code Editor - Built-in Monaco Editor (VS Code editor) with syntax highlighting
- Tree Navigation - Sidebar directory tree structure for easy navigation
- File Previews - Support for text files, images, and code files
- Security - CSRF protection, directory traversal prevention, path sanitization
- MySQL Integration - Connect and manage MySQL databases with Unix socket support
- Query Executor - Execute SQL queries with results display
- Table Browser - Browse table structures and data
- Export Features - Export query results to CSV/JSON
- Query History - Track and reuse recent queries
- Database Tree - Navigate databases and tables in sidebar
- Session-based authentication with timeout
- CSRF token protection for all forms
- Path sanitization and directory traversal prevention
- Configurable access credentials
- File type restrictions for editing
- Secure database connections with PDO
- Cross-platform permission checking
- Windows Server 2016, 2019, 2022 (IIS)
- Linux Distributions - Ubuntu, CentOS, Debian, Fedora, Amazon Linux, Alpine
- POSIX Permissions - Full Linux file permission display and management
- Unix Sockets - Optimized MySQL connections on Linux
- Platform Detection - Automatic Windows/Linux feature adaptation
- PHP 7.4 or higher (Recommended: PHP 8.0+)
- Web server (Apache, Nginx, or IIS)
- MySQL/MariaDB (optional, for database features)
- Modern web browser with JavaScript enabled
- Ubuntu 18.04+ (Apache2, Nginx)
- CentOS/RHEL 7+ (Apache, Nginx)
- Debian 9+ (Apache2, Nginx)
- Fedora 30+ (Apache, Nginx)
- Amazon Linux 2 (Apache, Nginx)
- Alpine Linux (Nginx, Lighttpd)
- Windows Server 2016, 2019, 2022 (IIS)
- Windows 10/11 (XAMPP, Laragon, WAMP)
- IIS 8.5+ with PHP support
Download and run our automated installation script:
# Download the installation script
curl -L -o install-linux.sh https://raw.githubusercontent.com/jerickalmeda/SecureFileHub/main/install-linux.sh
# Make it executable
chmod +x install-linux.sh
# Run the installer (supports Ubuntu, Debian, CentOS, Fedora, Amazon Linux)
./install-linux.shThe script will automatically:
- Install Apache, PHP, and MySQL
- Download SecureFileHub
- Set proper permissions
- Configure the web server
- Download
filemanager.phpfrom Releases - Copy to your IIS web directory (e.g.,
C:\inetpub\wwwroot\) - Ensure PHP is configured in IIS
- Access via:
http://localhost/filemanager.php
- Clone or download to your web root (e.g.,
C:\laragon\www\SecureFileHub\) - Start your web server and MySQL
- Access:
http://localhost/SecureFileHub/filemanager.php
# Clone the repository
git clone https://github.com/jerickalmeda/SecureFileHub.git
cd SecureFileHub
# Copy to your web server
cp filemanager.php /path/to/your/webserver/# Download latest version
wget https://github.com/jerickalmeda/SecureFileHub/releases/latest/download/filemanager.php
# Move to web directory
sudo mv filemanager.php /var/www/html/
sudo chown www-data:www-data /var/www/html/filemanager.php
sudo chmod 644 /var/www/html/filemanager.php- Username:
admin - Password:
filemanager123 β οΈ Important: Change these credentials immediately after installation!
Edit the following lines in filemanager.php (around line 5-6):
// Configuration
define('FM_USERNAME', 'admin'); // Change this username
define('FM_PASSWORD', 'filemanager123'); // Change this passwordExample:
define('FM_USERNAME', 'myusername');
define('FM_PASSWORD', 'MySecurePassword123!');Edit the database settings in filemanager.php (around line 11-14):
// Database Configuration
define('DB_HOST', 'localhost'); // Database server host
define('DB_USERNAME', 'root'); // Database username
define('DB_PASSWORD', ''); // Database password
define('DB_NAME', 'mysql'); // Default databaseExample for Production:
define('DB_HOST', 'mysql.example.com');
define('DB_USERNAME', 'dbuser');
define('DB_PASSWORD', 'SecureDBPassword123!');
define('DB_NAME', 'production_db');Modify session timeout (around line 7):
define('FM_SESSION_TIMEOUT', 3600); // 1 hour in secondsExamples:
- 30 minutes:
1800 - 2 hours:
7200 - 8 hours:
28800
By default, the file manager operates in its installation directory. To change the root directory, modify line 8:
define('FM_ROOT_PATH', __DIR__);By default, the file manager operates in its installation directory. To change the root directory, modify line 8:
define('FM_ROOT_PATH', __DIR__);Examples:
// Windows
define('FM_ROOT_PATH', 'C:\\inetpub\\wwwroot\\myfiles');
// Linux
define('FM_ROOT_PATH', '/var/www/html/files');
define('FM_ROOT_PATH', '/home/user/documents');For better performance on Linux, you can use Unix sockets:
// Enable Unix socket connection
define('DB_SOCKET', '/var/run/mysqld/mysqld.sock');
// Comment out or remove DB_HOST when using socketOn Linux systems, SecureFileHub displays:
- Octal permissions (755, 644, etc.)
- Read/Write/Execute flags
- Owner and Group information
- Detailed permission breakdown
-
Navigation
- Use the left sidebar tree to navigate directories
- Click folder icons to expand/collapse
- Breadcrumb shows current path
-
File Operations
- Upload: Use the upload form in the top section
- Create Folder: Enter folder name and click Create
- Create File: Enter filename with extension
- Edit Files: Click βοΈ icon next to text files
- Download: Click π₯ icon next to files
- Rename: Click βοΈ and modify the name
- Delete: Click ποΈ (requires confirmation)
-
Code Editor
- Supports syntax highlighting for PHP, HTML, CSS, JS, Python, Java, C++, SQL
- Auto-completion and error detection
- Save with Ctrl+S or Save button
- Format code with Format button
- Toggle visibility with Hide/Show Editor
-
Connection
- Switch to Database tab in main content area
- Select database from sidebar or dropdown
- Connection status shown in info panel
-
Query Execution
- Write SQL queries in the text area
- Select target database
- Use Quick Query buttons for common operations
- View results in formatted table
-
Table Management
- Browse table structure and data
- Use table browser for quick SELECT queries
- Export results to CSV or JSON
- View table structure with DESCRIBE
-
Query History
- Recent queries saved automatically
- Click history items to reload queries
- Stored in browser localStorage
// Use strong passwords with mixed characters
define('FM_PASSWORD', 'MyStr0ng!P@ssw0rd#2024');Create .htaccess in the same directory:
# Restrict access to PHP files
<Files "*.php">
Require ip 192.168.1.0/24 # Your IP range
# Or specific IPs: Require ip 192.168.1.100
</Files>
# Security headers
Header always set X-Content-Type-Options nosniff
Header always set X-Frame-Options DENY
Header always set X-XSS-Protection "1; mode=block"
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"server {
listen 80;
server_name your-domain.com;
root /var/www/html;
location /filemanager.php {
allow 192.168.1.0/24; # Your IP range
deny all;
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options DENY;
add_header X-XSS-Protection "1; mode=block";
try_files $uri =404;
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}# Secure file permissions
sudo chown www-data:www-data /var/www/html/filemanager.php
sudo chmod 644 /var/www/html/filemanager.php
# Secure directory permissions
sudo chown www-data:www-data /var/www/html/managed_files
sudo chmod 755 /var/www/html/managed_files
# For file uploads
sudo chmod 775 /var/www/html/uploads// Use dedicated database user with limited privileges
define('DB_USERNAME', 'filemanager_user'); // Not root
define('DB_PASSWORD', 'StrongDBPassword123!');
// Grant only necessary privileges:
// GRANT SELECT, INSERT, UPDATE, DELETE ON myapp.* TO 'filemanager_user'@'localhost';- Check PHP version (requires 7.4+)
- Verify file encoding is UTF-8
- Check for missing semicolons or brackets
- Verify MySQL service is running
- Check database credentials in configuration
- Confirm MySQL port (default 3306) is accessible
- Test connection:
mysql -h localhost -u username -p
- Check file/folder permissions
- On Windows: Ensure IIS_IUSRS has appropriate permissions
- On Linux: Use
chmod 755for directories,chmod 644for files
- Check
upload_max_filesizein php.ini - Verify
post_max_sizeis larger thanupload_max_filesize - Ensure target directory is writable
- Check internet connection (loads from CDN)
- Verify browser JavaScript is enabled
- Try different browser
- Check browser console for errors
Recommended php.ini settings:
upload_max_filesize = 100M
post_max_size = 100M
max_execution_time = 300
memory_limit = 256M
session.gc_maxlifetime = 3600Edit the Tailwind CSS classes in the HTML sections:
// Change header color (around line 500)
<header class="bg-purple-600 text-white shadow-lg"> // Was bg-blue-600
// Change button colors
<button class="bg-green-500 hover:bg-green-600"> // Success buttons
<button class="bg-red-500 hover:bg-red-600"> // Danger buttonsTo add support for new file types in the editor:
// Add to languageMap array (around line 1200)
const languageMap = {
'php': 'php',
'js': 'javascript',
'py': 'python',
'rb': 'ruby', // Add Ruby support
'go': 'go', // Add Go support
// ... existing entries
};
// Add to editableExts array (around line 150)
$editableExts = ['php', 'html', 'css', 'js', 'json', 'xml', 'txt', 'md', 'py', 'java', 'c', 'cpp', 'h', 'sql', 'ini', 'conf', 'log', 'rb', 'go'];Add custom SQL quick queries:
// Add buttons in the Database Manager section
<button onclick="setQuickQuery('SHOW PROCESSLIST;')" class="bg-gray-500 text-white px-2 py-1 rounded text-xs hover:bg-gray-600">Show Processes</button>
<button onclick="setQuickQuery('SHOW STATUS;')" class="bg-gray-500 text-white px-2 py-1 rounded text-xs hover:bg-gray-600">Show Status</button>- Increase PHP memory limit:
memory_limit = 512M - Adjust max execution time:
max_execution_time = 600 - Consider pagination for large file lists
- Use LIMIT clauses for large result sets
- Enable query cache in MySQL
- Use appropriate indexes on frequently queried tables
- Regular backups of the
filemanager.phpfile with your configurations - Database backups if using database features
- File system backups of managed directories
- Backup current configuration settings
- Download new version of
filemanager.php - Restore your configuration settings
- Test functionality
GitHub Repository: SecureFileHub
Clone the repository:
git clone https://github.com/jerickalmeda/SecureFileHub.git
cd SecureFileHubDownload latest release:
wget https://github.com/jerickalmeda/SecureFileHub/releases/latest/download/filemanager.phpTopics: file-manager, web-file-manager, php-file-manager, online-file-manager, file-browser, php, mysql, javascript, tailwindcss, monaco-editor, pdo, cross-platform, windows-server, linux, ubuntu, centos, debian, database-manager, code-editor, file-upload, authentication, security, csrf-protection, single-file, portable, self-hosted, apache, nginx, iis, admin-tools
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
# Clone your fork
git clone https://github.com/yourusername/SecureFileHub.git
cd SecureFileHub
# Set up development environment
# (Laragon, XAMPP, or your preferred local server)
# Make your changes and test
# Submit a pull requestFound a bug or have a feature request? Please open an issue with:
- Detailed description
- Steps to reproduce (for bugs)
- Your environment (PHP version, OS, browser)
- Screenshots (if applicable)
- Check the troubleshooting section above
- Verify your PHP and MySQL versions meet requirements
- Check web server error logs for detailed error messages
- Test with default configuration first
- Try the automated Linux installation script
When reporting issues, please include:
- PHP version (
php -v) - Web server type and version (Apache, Nginx, IIS)
- MySQL version (if using database features)
- Operating System (Windows Server, Ubuntu, CentOS, etc.)
- Browser and version
- Complete error messages from logs
- Steps to reproduce the issue
- Screenshots (if applicable)
We welcome feature requests! Please open an issue with:
- Clear description of the requested feature
- Use case and benefits
- Any implementation suggestions
This project is licensed under the MIT License - see the LICENSE file for details.
ποΈ SecureFileHub v2.0
Cross-Platform File & Database Management with Professional UI
β Star this project if you find it useful!
Report Bug β’ Request Feature β’ Documentation β’ Download v2.0
Made with β€οΈ by the SecureFileHub team
Supporting both Windows Server and Linux environments with enterprise-grade security and professional cPanel-style interface
Last updated: November 2025