milad / yii2-mongodb-upload-file
There is no license information available for the latest version (1.0.0) of this package.
Yii2 File processing through single collection
1.0.0
2018-10-13 08:00 UTC
Requires
- php: >=5.4.0
- yiisoft/yii2: >=2.0
- yiisoft/yii2-imagine: ~2.0.0
- yiisoft/yii2-mongodb: *
This package is auto-updated.
Last update: 2024-12-13 21:30:31 UTC
README
Yii2 file upload with database management
add component to your config
'fileManager' => [ 'class' => \miladh\file\FileManager::className(), 'alias' => \miladh\file\models\File::ALIAS_FRONTEND, 'db' => 'db', 'defaultImageThumbnail' => '@frontend/web/images/thumb-image.jpg', 'defaultDocumentThumbnail' => '@frontend/web/images/thumb-document.jpg', 'defaultAudioThumbnail' => '@frontend/web/images/thumb-audio.jpg', 'defaultVideoThumbnail' => '@frontend/web/images/thumb-video.jpg', 'defaultOtherThumbnail' => '@frontend/web/images/thumb-other.jpg', ]
do migration via console
php yii mongodb-migrate --migrationPath=@miladh/yii2-upload-file/src/migrations
getting fileManager
/** @var FileManager $fileManager */ $fileManager = \Yii::$app->fileManager;
uploading file from fileInstance
$fileInstance = UploadedFile::getInstanceByName('files'); /** @var miladh\file\models\File $file */ $file = $fileManager->upload($fileInstance);