The FileExplorerFSHelper class is a server-side PHP helper designed to bridge the FileExplorer JavaScript widget with a physical file system. It handles common server-side actions such as directory listings, file uploads, renaming, moving, and deleting files.
Key Requirements
- Permissions: The directories used for files (e.g.,
/files/) and thumbnails (e.g., /thumbs/) must be writable by the web server user (e.g., www-data). - Maintenance: It is recommended to run a nightly cron job to clear out
.tmp files (failed/abandoned uploads), old files in the recycling bin, and old thumbnail directories.
Implementation Pattern
To handle file explorer actions, use the FileExplorerFSHelper::HandleActions method. This method requires an action name prefix, a base directory path, and a configuration options array.
<?php
require_once "server-side-helpers/file_explorer_fs_helper.php";
$options = array(
"base_url" => "https://cubiclesoft.com/myapp/files/",
"protect_depth" => 1,
"recycle_to" => "Recycle Bin",
"temp_dir" => "/tmp",
"dot_folders" => false,
"allowed_exts" => ".jpg, .jpeg, .png, .gif, .svg, .txt",
"allow_empty_ext" => true,
"thumbs_dir" => "/var/www/myapp/thumbs",
"thumbs_url" => "https://cubiclesoft.com/myapp/thumbs/",
"thumb_create_url" => "https://cubiclesoft.com/myapp/?action=file_explorer_thumbnail&xsrftoken=qwerasdf",
"refresh" => true,
"rename" => true,
"file_info" => false,
"load_file" => false,
"save_file" => false,
"new_folder" => true,
"new_file" => ".txt",
"upload" => true,
"upload_limit" => 20000000,
"download" => "user123-" . date("Y-m-d_H-i-s") . ".zip",
"download_module" => "",
"download_module_prefix" => "",
"copy" => true,
"move" => true,
"recycle" => true,
"delete" => true
);
// Handle actions with prefix 'file_explorer_' in the directory '/var/www/myapp/files'
FileExplorerFSHelper::HandleActions("action", "file_explorer_", "/var/www/myapp/files", $options);
?>