Files and downloads
This page is for website creators who offer documents, brochures or software for download. Files are content objects
with a file field (ezbinaryfile); downloads go through the content/download view, which checks permissions
before sending the file.
Contents
- How a download works
- Download links in templates
- Protected downloads
- Searching inside files
- Large files
- Checklist
How a download works
- A File object (class
file) holds the document in itsfileattribute (datatypeezbinaryfile). Uploads of non-image files become File objects (DefaultClass=fileinsettings/upload.ini). - The download address is
content/download/<object ID>/<attribute ID>(kernel/content/module.php, viewdownload, functionread). The view checks that the visitor may read the object, then sends the file. - Because of that check, a file in a members-only section can only be downloaded by members.
Download links in templates
The datatype's view template renders a link with name and size:
{attribute_view_gui attribute=$node.data_map.file}Your own markup:
{def $file = $node.data_map.file}
{if $file.has_content}
<a href={concat( 'content/download/', $file.contentobject_id, '/', $file.id, '/file/', $file.content.original_filename )|ezurl}>
{$node.name|wash} ({$file.content.mime_type|wash}, {$file.content.filesize|si( byte )})
</a>
{/if}
{undef $file}Tell visitors the format and size before they click; it is also an accessibility requirement for many sites.
Protected downloads
| Goal | How |
|---|---|
| Members-only files | put them in a section only members may read (Sections and object states) |
| Files for one customer group | a subtree limitation on content/read for that group |
| A time-limited document | hide it, or move it to a section visitors cannot read, when the time is over |
Do not link files directly from var/.../storage/: that bypasses the permission check. The shipped rewrite rules
serve stored images directly for speed; for documents rely on content/download.
Searching inside files
settings/binaryfile.ini has handlers that extract text from PDF and Word files for the search index ([PDFHandlerSettings],
[WordHandlerSettings]), using external programs you install. With Solr (ezfind), file contents can be indexed too
(Search with ezfind and Solr).
Large files
- PHP's
upload_max_filesizeandpost_max_sizelimit what editors can upload; set them inphp.iniof the web PHP. - A file field can have a maximum size in the class.
- Very large files (videos) are better hosted on a service built for them and embedded.
- The
enhancedezbinaryfileextension adds options to the file datatype (enhancedezbinaryfile).
Checklist
- To do: Download links show format and size.
- To do: Protected files sit in a protected section, and the download is tested logged out.
- To do: Upload limits in
php.inifit the largest file editors need. - To do: File names are readable (they appear in the download address).
Related pages
- Organizing the media library
- Media and uploads (for editors)
- PDF exports
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.