top of page
  • minghindbeefsliqua

Elfinder: The best open-source file manager for web development



elFinder Download Function: How to Use It and Why You Need It




If you are looking for a web-based file manager that is easy to use, flexible, and powerful, you might want to check out elFinder. In this article, we will explain what elFinder is, what features and benefits it offers, and how to install and configure it. We will also focus on one of its most useful features: the download function. We will show you how to download files and folders with elFinder, and how to customize the download function according to your needs.


What is elFinder?




elFinder is an open-source file manager for web, written in JavaScript using jQuery and jQuery UI. It was created with the inspiration of simplicity and convenience of Finder program used in Mac OS X operating system. It allows you to perform all operations with files and folders on a remote server, such as copy, move, upload, create, rename, delete, etc. It also supports various storage drivers, such as local file system, MySQL, FTP, SFTP, Box, Dropbox, Google Drive, OneDrive, AWS S3, Azure, and more.




elfinder download function



Features and benefits of elFinder




Some of the features and benefits of elFinder are:



  • It has a user-friendly interface that resembles the MacOS Finder or Windows Explorer. You can switch between list and icons view, use keyboard shortcuts, drag and drop files and folders, and access a rich context menu and toolbar.



  • It is mobile-friendly and responsive. It adapts to different screen sizes and devices, and offers a touch-friendly view for smartphones and tablets.



  • It supports multiple languages and RTL (right-to-left) layout. You can easily change the language and direction of the interface according to your preference.



  • It has a high-performance server backend and a light client UI. It uses JSON as the communication format between the client and the server, which makes it fast and efficient.



  • It supports multi-root functionality. You can mount different volumes from different sources and access them from one interface.



  • It supports archives creation and extraction. You can create or extract zip, rar, 7z, tar, gzip, bzip2 files with elFinder.



  • It supports file preview and editing. You can preview common file types such as images, videos, audio, text, PDF, etc. You can also edit text files and images with elFinder.



  • It supports custom information in info dialog. You can add your own fields and values to the file or folder information dialog.



  • It supports custom CSS class function for custom folder icon. You can assign different icons to different folders based on your criteria.



  • It supports connector plugins. You can extend the functionality of elFinder by adding plugins that handle events such as upload, download, rename, delete, etc.



  • It is easy to integrate with web editors. You can use elFinder as a file browser or picker for web editors such as elRTE, CKEditor, TinyMCE, etc.



  • It has a flexible configuration of access rights, upload file types, user interface, and other options. You can customize elFinder according to your requirements.



How to install and configure elFinder




To install and configure elFinder on your web server, you need to follow these steps:



))">Composer to install it.


  • Upload the elFinder folder to your web server. Make sure that the PHP version is 5.3 or higher, and that the required PHP extensions are enabled (mbstring, fileinfo, zip, etc.).



  • Create a folder where you want to store your files and folders. Make sure that the folder has write permission for the web server.



  • Edit the connector configuration file (php/connector.minimal.php) and set the root path, URL, and alias of your folder. You can also change other options such as access control, upload settings, thumbnails, etc.



  • Include the elFinder CSS and JS files in your web page. You can also customize the theme and language of elFinder.



  • Create a div element with an id attribute (for example, id="elfinder") in your web page where you want to display elFinder.



Initialize elFinder with jQuery in your web page. For example:


$(document).ready(function() $('#elfinder').elfinder( // set your elFinder options here url : 'php/connector.minimal.php', // connector URL lang: 'en', // language height: 600 // height of elFinder ); );




For more details and examples, you can refer to the .


How to use elFinder download handler


elFinder download event javascript callback


elFinder download folder as zip


elFinder download option not working


elFinder download multiple files


elFinder download file from URL


elFinder download file with custom name


elFinder download file from S3


elFinder download file from Google Drive


elFinder download file from Dropbox


elFinder download file from OneDrive


elFinder download file from FTP


elFinder download file from MySQL


elFinder download file from Box


elFinder download file from Azure


elFinder download file from Digital Ocean Spaces


elFinder download file with PHP


elFinder download file with jQuery


elFinder download file with Ajax


elFinder download file with chunked upload


elFinder download file with progress bar


elFinder download file with resume support


elFinder download file with authentication


elFinder download file with encryption


elFinder download file with compression


elFinder download file with metadata


elFinder download file with custom headers


elFinder download file with CORS support


elFinder download file with drag and drop


elFinder download file with keyboard shortcuts


elFinder download file with icons view


elFinder download file with list view


elFinder download file with preview mode


elFinder download file with quicklook plugin


elFinder download file with context menu


elFinder download file with toolbar button


elFinder download file with command line interface


elFinder download file with REST API


elFinder download file with GraphQL API


elFinder download file with WebSockets API


elFinder download file with WebRTC API


elFinder download file with WebAssembly API


elFinder download file with Service Worker API


elFinder download file with Web Worker API


elFinder download file with IndexedDB API


elFinder download file with LocalStorage API


elFinder download file with Cache API


elFinder download file with Fetch API


elFinder download file with Blob API


What is the download function in elFinder?




The download function in elFinder allows you to download files and folders from the server to your local computer. You can download single or multiple files or folders at once, depending on your configuration. There are three ways to download files and folders with elFinder: by double-clicking, by using the context menu, and by using the toolbar.


How to download files and folders with elFinder




Download by double-clicking




To download a file by double-clicking, you just need to double-click on the file icon or name in elFinder. A dialog box will appear asking you to save the file or open it with a program. Choose the option you prefer and click OK. The file will be downloaded to your local computer.


To download a folder by double-clicking, you need to enable the folder download option in the connector configuration file (php/connector.minimal.php). Find the line that says:


'bind' => array( 'mkdir mkfile rename duplicate upload rm paste' => 'logger' )


and add 'download' => 'force_download' after 'logger'. It should look like this:


'bind' => array( 'mkdir mkfile rename duplicate upload rm paste' => 'logger', 'download' => 'force_download' )


This will force elFinder to download folders as zip files instead of opening them. After saving the file, you can double-click on any folder in elFinder and a dialog box will appear asking you to save the zip file or open it with a program. Choose the option you prefer and click OK. The folder will be downloaded as a zip file to your local computer.


Download by using the context menu




To download a file or a folder by using the context menu, you need to right-click on the file or folder icon or name in elFinder. A context menu will appear with various options. Choose Download from the menu and a dialog box will appear asking you to save the file or folder or open it with a program. Choose the option you prefer and click OK. The file or folder will be downloaded to your local computer.


You can also download multiple files or folders by using the context menu. To do that, you need to select multiple files or folders by holding down Ctrl (or Command on Mac) key and clicking on them. Then right-click on any of them and choose Download from the menu. A dialog box will appear asking you to save a zip file containing all the selected files or folders or open it with a program. Choose the option you prefer and click OK. The zip file will be downloaded to your local computer.


Download by using the toolbar




folder will be downloaded to your local computer.


You can also download multiple files or folders by using the toolbar. To do that, you need to select multiple files or folders by holding down Ctrl (or Command on Mac) key and clicking on them. Then click on the Download button on the toolbar. A dialog box will appear asking you to save a zip file containing all the selected files or folders or open it with a program. Choose the option you prefer and click OK. The zip file will be downloaded to your local computer.


How to customize the download function in elFinder




If you want to customize the download function in elFinder, you can use some of the options and events available in the connector configuration file (php/connector.minimal.php) and the client initialization script. Here are some examples of how to customize the download function in elFinder:


Add a JavaScript function to the download event




If you want to add a JavaScript function to the download event, you can use the bind option in the client initialization script. For example, if you want to show an alert message when a file or folder is downloaded, you can use this code:


$(document).ready(function() $('#elfinder').elfinder( // set your elFinder options here url : 'php/connector.minimal.php', // connector URL lang: 'en', // language height: 600, // height of elFinder bind: download: function(event, elfinderInstance) alert('You have downloaded ' + event.data.added.length + ' item(s)'); ); );


This will bind a function to the download event that will alert the number of items downloaded.


Enable or disable folder download




If you want to enable or disable folder download, you can use the zipdl option in the connector configuration file (php/connector.minimal.php). This option determines whether folders can be downloaded as zip files or not. By default, it is set to true, which means folder download is enabled. If you want to disable folder download, you can set it to false. For example:


'zipdl' => false


This will disable folder download and prevent users from downloading folders as zip files.


Change the download file name or format




If you want to change the download file name or format, you can use the zipdlHandler option in the connector configuration file (php/connector.minimal.php). This option allows you to specify a custom PHP function that will handle the zip file creation and output. You can use this function to modify the file name, format, compression level, password, etc. of the zip file. For example, if you want to add a prefix and a timestamp to the zip file name, you can use this code:


'zipdlHandler' => function($cmd, $args, $elfinder) $files = $args['targets']; $name = 'myzip_' . date('YmdHis') . '.zip'; $zip = new ZipArchive(); $tmp = tempnam(sys_get_temp_dir(), 'ELF'); if ($zip->open($tmp, ZipArchive::CREATE) === true) foreach ($files as $hash) $volume = $elfinder->getVolume($hash); if ($volume && ($file = $volume->file($hash))) if ($file['mime'] === 'directory') $volume->addSubdirsToZip($zip, $file); else $path = $volume->getPath($hash); $zip->addFile($volume->realpath($hash), $path); $zip->close(); header('Content-Type: application/zip'); header('Content-Disposition: attachment; filename="' . $name . '"'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . filesize($tmp)); readfile($tmp); unlink($tmp);


This will create a custom zip file handler that will add a prefix and a timestamp to the zip file name.


Conclusion




Summary of the main points




Finder, and how to customize the download function according to our needs. We have learned how to download files and folders by double-clicking, by using the context menu, and by using the toolbar. We have also learned how to add a JavaScript function to the download event, how to enable or disable folder download, and how to change the download file name or format.


Call to action and further resources




If you are interested in using elFinder as your web-based file manager, you can download it from on GitHub, Stack Overflow, or Google Groups to ask questions, report issues, or contribute to the project.


We hope you have enjoyed this article and learned something new. If you have any feedback or suggestions, please let us know in the comments below. Thank you for reading!


Frequently Asked Questions




Here are some of the frequently asked questions about elFinder download function:


Q: How can I limit the size of the zip file when downloading multiple files or folders?




A: You can use the maxArcFilesSize option in the connector configuration file (php/connector.minimal.php) to set the maximum size of the zip file in bytes. If the zip file exceeds this size, elFinder will show an error message and abort the download. For example:


'maxArcFilesSize' => 104857600 // 100 MB


This will limit the zip file size to 100 MB.


Q: How can I prevent users from downloading certain files or folders?




A: You can use the access control option in the connector configuration file (php/connector.minimal.php) to set the permissions for each file or folder. You can use a PHP function or an array of rules to determine whether a file or folder is readable, writable, locked, hidden, or has other attributes. For example:


'accessControl' => function($attr, $path, $data, $volume) // do not allow access to hidden files or folders if (strpos(basename($path), '.') === 0) return false; // do not allow download for files with .exe extension if ($attr == 'read' && pathinfo($path, PATHINFO_EXTENSION) == 'exe') return false; // allow all other operations return null;


This will prevent users from accessing hidden files or folders, and from downloading files with .exe extension.


Q: How can I change the default download behavior of elFinder?




A: You can use the handlers option in the client initialization script to override the default download behavior of elFinder. You can specify a custom JavaScript function that will handle the download event before or after it is executed by elFinder. For example, if you want to open a new window instead of showing a dialog box when downloading a file, you can use this code:


$(document).ready(function() $('#elfinder').elfinder( // set your elFinder options here url : 'php/connector.minimal.php', // connector URL lang: 'en', // language height: 600, // height of elFinder handlers: download: function(event) event.preventDefault(); // prevent default download behavior window.open(event.data.url); // open a new window with the download url ); );


This will override the default download behavior and open a new window instead.


Q: How can I add a watermark or a signature to the downloaded files?




A: You can use the connector plugins option in the connector configuration file (php/connector.minimal.php) to add a custom PHP function that will modify the downloaded files before they are sent to the client. You can use any PHP library or function that can manipulate files, such as GD, ImageMagick, PDFlib, etc. For example, if you want to add a watermark image to the downloaded images, you can use this code:


'plugin' => array( 'Watermark' => array( 'enable' => true, 'marginRight' => 5, 'marginBottom' => 5, 'quality' => 95, 'transparency' => 70, 'targetType' => IMG_GIF IMG_JPG IMG_PNG IMG_WBMP ) ),


This will enable the Watermark plugin and add a watermark image (watermark.png) to the bottom right corner of the downloaded images with some margin, quality, transparency, and target type settings.


Q: How can I download files or folders from elFinder to another web service or application?




A: You can use the netmount option in the client initialization script to mount a web service or application as a volume in elFinder. You can then copy or move files or folders from elFinder to the mounted volume. For example, if you want to download files or folders from elFinder to Dropbox, you can use this code:


$(document).ready(function() $('#elfinder').elfinder( // set your elFinder options here url : 'php/connector.minimal.php', // connector URL lang: 'en', // language height: 600, // height of elFinder netmount: dropbox: name: 'Dropbox', id: 'dropbox', csscls: 'dropbox', syncInterval: 5000, options: key: 'your_dropbox_app_key', secret: 'your_dropbox_app_secret', sandbox: false ); );


This will mount Dropbox as a volume in elFinder and allow you to download files or folders from elFinder to Dropbox by copying or moving them.





This is the end of the article. I hope you have found it helpful and informative. If you have any questions or comments, please feel free to contact me. Thank you for reading! 44f88ac181


1 view0 comments

Recent Posts

See All
!
Widget Didn’t Load
Check your internet and refresh this page.
If that doesn’t work, contact us.
bottom of page