efw elFinder File Manager Example

Overview

The efw framework integrates the elFinder file manager, enabling complete file management functionality in web applications through simple tags. elFinder is a popular file manager based on JavaScript and PHP. The efw framework encapsulates it, provides a Java connector, and offers it in the form of JSP tags.

Core Files

  1. Basic Usage Example: helloElfinder.jsp
  2. Security Configuration Test Example: helloElfinder4.jsp

Features

1. Basic Usage

elFinder can be invoked with a simple tag:

<efw:elFinder home=""/>

2. Path Configuration

Supports both relative and absolute path modes:

<!-- Relative path -->
<efw:elFinder home="upload"/>

<!-- Absolute path -->
<efw:elFinder home="C:\Windows\Microsoft.NET\Framework64" isAbs="true"/>

3. Security Configuration

efw detects and reports errors when paths contain ... Additionally, it provides various security configuration options:

Protected Mode (protected="true")

Read-only Mode (readonly="true")

// Toggle read-only mode
elfinder1.setReadOnly(true);  // Enable read-only
elfinder1.setReadOnly(false); // Disable read-only

Absolute Path Mode (isAbs="true")

Log save function (saveLogFunc="myFunc")

4. API Functions

The elFinder component provides essential JavaScript APIs:

// Change current directory
elfinder1.setHome('C:/EFW_ALL');

// Toggle read-only mode
elfinder1.setReadOnly(true);

Security Considerations

1. Path Traversal Protection

2. File Operation Risks

3. Directory Size Limitations

4. Network Environment Considerations

Usage Recommendations

  1. Development Environment: Absolute paths can be used for convenient access to various directories
  2. Production Environment: Use relative paths and protected mode, restricting access to specific directories
  3. Sensitive Operations: Combine with read-only mode to prevent accidental operations
  4. Performance Considerations: Avoid pointing to directories containing large numbers of files

Extended Features

1. File Preview

elFinder supports preview for various file types:

Summary

The efw elFinder component provides powerful and convenient file management functionality, delivering an experience similar to desktop explorers through simple tag invocations. Proper configuration of security options balances convenience and safety, making it suitable for various web application scenarios.

Special attention should be paid to path security and permission control during use to avoid potential security risks. In production environments, it is recommended to use relative paths, protected mode, and appropriate read-only restrictions to ensure system security.