The HumHub core module humhub/modules/file provides a generic file management which can be used in custom modules to store and read files including access control.
The file management is available for
There are two typical variants for file upload implementations.
Uploads via ActiveForm (Direct Mapping)
For direct File Uploads via ActiveForm, see Yii2 Guide - Uploading files.
Example to add an uploaded file to HumHub file storage:
Example (Step 3):
To read mapped files of an ActiveRecord, use the
Converter & Variants
Converters are used to create variants (e.g. different file formats or images sizes) of an existing file. All converted files (variants) will be automatically stored with the original file.
You can also create own Converters by using
Note: Always create file variants (e.g. previews) on the fly - variants may deleted during the upgrade progress.
HumHub bundles Imagine as Yii 2 Extension.
Please see the Imagine Extension for Yii 2 documentation for more details.