To specify source file use the [[file]] attribute. It can be specified in one of the following ways:
- string - full name of the file, which content should be stored in GridFS
- \yii\web\UploadedFile - uploaded file instance, which content should be stored in GridFS
For example:
php
$record = new ImageFile();
$record->file = '/path/to/some/file.jpg';
$record->save();
You can also specify file content via [[newFileContent]] attribute:
php
$record = new ImageFile();
$record->newFileContent = 'New file content';
$record->save();
Note: [[newFileContent]] always takes precedence over [[file]].