[
](L## Sup## - Path-based na- PSR-12 co## Auth## Author
Dhiraj Dhiman
- GitHub: @dhiraj-nishthatechnosoft
- Email: dhiraj@nishthatechnosoft.com
---Dhiman**
- GitHub: @dhiraj-nishthatechnosoft
- Email: dhiraj@nishthatechnosoft.com
β If you find this project useful, please consider giving it a star on GitHub!Comprehensive documentation
Dhiraj Dhiman
- GitHub: @dhiraj-nishthatechnosoft
- Email: dhiraj@nishthatechnosoft.com
---- Bulk operations support
- Archive handling (ZIP/TAR.GZ)
- Modern responsive UI
- PSR-12 compliant code
- Comprehensive documentation
Dhiraj Dhiman
- GitHub: @dhiraj-nishthatechnosoft
- Email: dhiraj@nishthatechnosoft.com
--- Dhiman**
- GitHub: @dhiraj-nishthatechnosoft
- Email: dhiraj@nishthatechnosoft.com
β If you find this project useful, please consider giving it a star on GitHub! Dhiman**
- GitHub: @dhiraj-nishthatechnosoft
- Email: dhiraj@nishthatechnosoft.com
β If you find this project useful, please consider giving it a star on GitHub!ocumentation](https://github.com/dhiraj-nishthatechnosoft/php-file-manager/wiki)
- π Issue Tracker
- π¬ DiscussionsDocumentation
- π Issue Tracker
- π¬ DiscussionsNSE)
A modern, feature-rich web-based file manager built with PHP 8.0+. This package provides a complete file management solution with advanced features like bulk operations, archive handling, path-based navigation, and a responsive user interface.
- Password-based authentication with session management
- Path traversal protection preventing unauthorized access
- File type validation with configurable allowed extensions
- File size limits to prevent abuse
- CSRF protection and secure session handling
- Create, edit, rename, and delete files and directories
- Upload files with drag-and-drop support
- Download files and directories
- Copy and move items between directories
- Bulk operations for multiple files/folders
- Create archives (ZIP format) from selected files/folders
- Extract archives (ZIP, TAR.GZ, TGZ) to current or custom directory
- Bulk archive creation for multiple items
- Archive preview before extraction
- Responsive design works on desktop and mobile
- Path-based navigation with autocomplete suggestions
- File type icons with visual file identification
- Drag-and-drop file uploads
- Real-time feedback with SweetAlert2 notifications
- Path autocomplete for quick navigation
- File size formatting (B, KB, MB, GB)
- Last modified timestamps
- Directory breadcrumbs
- Keyboard shortcuts for common actions
composer require nishthatechnosoft/php-file-manager
- Download the latest release
- Extract to your project directory
- Install dependencies:
composer install
<?php
require_once 'vendor/autoload.php';
use Dhiraj\PhpFileManager\FileManager;
// Basic configuration
$config = [
'root_path' => __DIR__ . '/files',
'password' => 'your-secure-password',
'max_file_size' => 50 * 1024 * 1024, // 50MB
];
// Initialize and run
$fileManager = new FileManager($config);
$fileManager->run();
Create filemanager-config.php
:
<?php
return [
'root_path' => '/path/to/files',
'password' => 'secure-password-123',
'max_file_size' => 100 * 1024 * 1024, // 100MB
'allowed_extensions' => [
'txt', 'pdf', 'jpg', 'png', 'zip', 'doc', 'xls'
],
'enable_bulk_operations' => true,
'enable_archive_operations' => true,
];
Then in your PHP file:
<?php
require_once 'vendor/autoload.php';
use Dhiraj\PhpFileManager\FileManager;
$config = require 'filemanager-config.php';
$fileManager = new FileManager($config);
$fileManager->run();
Option | Type | Default | Description |
---|---|---|---|
root_path |
string | $_SERVER['DOCUMENT_ROOT'] |
Root directory for file operations |
upload_path |
string | {root_path}/uploads |
Directory for file uploads |
password |
string | 'admin123' |
Authentication password |
max_file_size |
integer | 52428800 (50MB) |
Maximum file upload size in bytes |
allowed_extensions |
array | See below | Array of allowed file extensions |
session_name |
string | 'php_file_manager' |
Session name for authentication |
enable_compression |
boolean | true |
Enable file compression features |
enable_bulk_operations |
boolean | true |
Enable bulk file operations |
enable_archive_operations |
boolean | true |
Enable archive creation/extraction |
[
'txt', 'php', 'html', 'css', 'js', 'json', 'xml', 'md', 'log',
'zip', 'tar', 'gz', 'pdf', 'doc', 'docx', 'xls', 'xlsx',
'ppt', 'pptx', 'jpg', 'jpeg', 'png', 'gif', 'svg', 'mp3',
'wav', 'mp4', 'avi', 'mov'
]
$fileManager = new FileManager([
'password' => hash('sha256', 'my-secret-password'),
'session_name' => 'my_app_filemanager',
]);
$fileManager = new FileManager([
'allowed_extensions' => ['txt', 'pdf', 'jpg', 'png'],
'max_file_size' => 10 * 1024 * 1024, // 10MB limit
]);
$fileManager = new FileManager([
'root_path' => '/var/www/uploads',
'password' => $_ENV['FILEMANAGER_PASSWORD'],
'max_file_size' => 200 * 1024 * 1024, // 200MB
'allowed_extensions' => [
'pdf', 'doc', 'docx', 'xls', 'xlsx',
'jpg', 'jpeg', 'png', 'gif'
],
]);
- Change Default Password: Always use a strong, unique password
- Restrict File Types: Only allow necessary file extensions
- Set Upload Limits: Configure appropriate file size limits
- Use HTTPS: Always serve over encrypted connections
- Restrict Access: Use
.htaccess
or server config to limit access - Regular Updates: Keep the package updated for security patches
# Restrict access to file manager
<Files "filemanager.php">
Require ip 192.168.1.0/24
# Or require authentication
# AuthType Basic
# AuthName "File Manager"
# AuthUserFile /path/to/.htpasswd
# Require valid-user
</Files>
use Dhiraj\PhpFileManager\FileManager;
use Dhiraj\PhpFileManager\Resources\ResourceManager;
$fileManager = new FileManager($config);
$resourceManager = $fileManager->getResourceManager();
// Get CSS content for custom styling
$css = $resourceManager->getCssContent();
// Get JavaScript for custom integration
$js = $resourceManager->getJsContent();
// In a Laravel controller
public function fileManager()
{
$config = config('filemanager');
$fileManager = new \Dhiraj\PhpFileManager\FileManager($config);
ob_start();
$fileManager->run();
$output = ob_get_clean();
return response($output);
}
// In a Symfony controller
use Dhiraj\PhpFileManager\FileManager;
use Symfony\Component\HttpFoundation\Response;
public function fileManager(): Response
{
$config = $this->getParameter('filemanager');
$fileManager = new FileManager($config);
ob_start();
$fileManager->run();
$content = ob_get_clean();
return new Response($content);
}
Override the default CSS by including your own stylesheet after the package CSS:
<link rel="stylesheet" href="path/to/filemanager-styles.css">
<link rel="stylesheet" href="path/to/your-custom.css">
Extend functionality by adding your own JavaScript:
<script src="path/to/filemanager-script.js"></script>
<script>
// Your custom JavaScript
document.addEventListener('DOMContentLoaded', function() {
// Custom functionality here
});
</script>
- PHP 8.0 or higher
- Composer
- Extensions: zip, phar, json, session
git clone https://github.com/dhiraj-nishthatechnosoft/php-file-manager.git
cd php-file-manager
composer install
composer test
# Check code style
composer phpcs
# Fix code style
composer fix-cs
# Static analysis
composer phpstan
- Initial release
- Complete file management functionality
- PSR-12 compliant code
- Composer package structure
- Comprehensive documentation
- 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
- Follow PSR-12 coding standards
- Add tests for new functionality
- Update documentation as needed
- Ensure backward compatibility
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with modern PHP practices
- Uses SweetAlert2 for notifications
- Inspired by popular file managers
- Community feedback and contributions
- Issues: GitHub Issues
- Documentation: GitHub Wiki
- Discussions: GitHub Discussions
Made with β€οΈ by Dhiraj Dhiman
- π Secure Authentication - Password-protected access with session management
- π File & Folder Operations - Create, rename, delete, copy, and move files/folders
- π¦ Archive Support - Create and extract ZIP/TAR.GZ archives
- οΏ½ Bulk Operations - Select and operate on multiple files simultaneously
- π€οΈ Path-Based Navigation - Direct path input with auto-suggestions
- π File Editor - Built-in text editor for code files
- β¬οΈ File Upload - Drag and drop file uploads
- π¨ Modern UI - Clean, responsive interface with dark mode support
- π Search & Filter - Quick file search and filtering
- π File Information - File sizes, modification dates, and permissions
composer require nishthatechnosoft/php-file-manager
- Download the latest release from GitHub
- Extract files to your web directory
- Install dependencies:
composer install
<?php
require_once 'vendor/autoload.php';
use Dhiraj\PhpFileManager\FileManager;
// Create file manager instance
$fileManager = new FileManager([
'root_path' => '/path/to/your/files',
'password' => 'your-secure-password'
]);
// Run the application
$fileManager->run();
<?php
require_once 'vendor/autoload.php';
use Dhiraj\PhpFileManager\FileManager;
$config = [
'root_path' => '/var/www/files',
'upload_path' => '/var/www/uploads',
'max_file_size' => 100 * 1024 * 1024, // 100MB
'allowed_extensions' => ['txt', 'pdf', 'jpg', 'png', 'zip'],
'password' => 'super-secure-password',
'session_name' => 'my_file_manager',
'enable_compression' => true,
'enable_bulk_operations' => true,
'enable_archive_operations' => true
];
$fileManager = new FileManager($config);
$fileManager->run();
Option | Type | Default | Description |
---|---|---|---|
root_path |
string | $_SERVER['DOCUMENT_ROOT'] |
Root directory for file operations |
upload_path |
string | {root_path}/uploads |
Directory for uploaded files |
max_file_size |
int | 52428800 (50MB) |
Maximum file upload size in bytes |
allowed_extensions |
array | See config | Array of allowed file extensions |
password |
string | admin123 |
Authentication password |
session_name |
string | php_file_manager |
Session variable name |
enable_compression |
bool | true |
Enable/disable compression features |
enable_bulk_operations |
bool | true |
Enable/disable bulk operations |
enable_archive_operations |
bool | true |
Enable/disable archive operations |
- Path Validation - Prevents directory traversal attacks
- File Type Filtering - Configurable allowed file extensions
- Size Limits - Configurable file size restrictions
- Session Management - Secure session handling with timeouts
- Input Sanitization - All user inputs are sanitized
- CSRF Protection - Cross-Site Request Forgery protection
public function __construct(array $config = [])
public function run(): void // Run the application
public function getConfig(): Configuration // Get configuration instance
public function getAuth(): AuthenticationService // Get auth service
public function getSecurity(): SecurityService // Get security service
public function getFileController(): FileController // Get file controller
public function get(string $key, mixed $default = null): mixed
public function set(string $key, mixed $value): void
public function getRootPath(): string
public function getMaxFileSize(): int
public function getAllowedExtensions(): array
public function isExtensionAllowed(string $filename): bool
public function createFile(string $filename, string $dir): void
public function createFolder(string $foldername, string $dir): void
public function deleteItem(string $item, string $dir): void
public function renameItem(string $oldName, string $newName, string $dir): void
public function copyItem(string $item, string $destination, string $currentDir): void
public function moveItem(string $item, string $destination, string $currentDir): void
public function bulkDelete(array $items, string $dir): void
public function bulkCopy(array $items, string $destination, string $currentDir): void
public function bulkMove(array $items, string $destination, string $currentDir): void
public function createArchiveWithName(string $archiveName, array $items, string $dir): void
public function unarchiveFile(string $archiveFile, string $dir): void
public function unarchiveToPath(string $archiveFile, string $destination, string $conflictResolution, string $currentDir): void
- Direct path input with
/
prefix for absolute paths - Auto-suggestions while typing paths
- Keyboard navigation (arrow keys, enter)
- Automatic directory creation
- Multi-select with checkboxes
- Keyboard shortcuts (Ctrl+A for select all)
- Bulk copy, move, delete, and archive operations
- Syntax highlighting for common file types
- Auto-save functionality
- Full-screen editing mode
- Chrome 60+
- Firefox 55+
- Safari 11+
- Edge 16+
- PHP 8.0 or higher
- PHP Extensions:
zip
,phar
,json
- Web server (Apache, Nginx, etc.)
composer test
composer phpcs
composer phpstan
composer fix-cs
- 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
This project is licensed under the MIT License - see the LICENSE file for details.
- Initial release
- Complete file management functionality
- Path-based navigation system
- Bulk operations support
- Archive handling (ZIP/TAR.GZ)
- Modern responsive UI
- PSR-12 compliant code
- Comprehensive documentation
Dhiraj Dhiman
- GitHub: @dhiraj-nishthatechnosoft
- Email: dhiraj@nishthatechnosoft.com
β If you find this project useful, please consider giving it a star on GitHub!
- π Markdown files
- π¦ Archive files
- πΌοΈ Image files
- π΅ Audio files
- π¬ Video files
- π Other files
- Change Default Password: Always change the default password in production
- Restrict Access: Consider additional IP-based restrictions
- File Permissions: Set appropriate file system permissions
- HTTPS: Use HTTPS in production environments
- File Type Validation: The system restricts editable file types for security
- PHP 5.6 or higher
- Web server (Apache, Nginx, etc.)
- ZipArchive extension for archive functionality
- Write permissions on the target directory
- Permission Denied: Ensure web server has write permissions
- Upload Fails: Check
upload_max_filesize
andpost_max_size
in php.ini - Archive Creation Fails: Ensure ZipArchive extension is installed
- Can't Edit Files: Check if file extension is in ALLOWED_EXTENSIONS array
- "File not found": File doesn't exist or was moved
- "Permission denied": Insufficient file system permissions
- "Upload failed": File too large or upload directory not writable
- "Archive creation failed": ZipArchive extension not available
This project is open source and available under the MIT License.
Feel free to submit issues, fork the repository, and create pull requests for any improvements.
- Initial release
- Basic file management operations
- Archive creation functionality
- Responsive web interface
- Security features