range( 0, 5 ) ], ['file', 'required', 'when' => function(){ return !$this->file_type; } , 'whenClient' => $client_func], [['file'], 'file', 'extensions' => ['csv', 'xlsx', 'xml', 'xls', 'txt'], 'checkExtensionByMimeType' => false ], ['file_path', 'safe'], ]; } public function attributeLabels() { return [ 'file' => Yii::t('app', 'Custom file'), ]; } public function readFile( $options = [] ){ $data = Yii::$app->multiparser->parse( $this->file_path, $options ); if( !is_array( $data ) || count($data) == 0 ){ throw new ErrorException("Reading error from file - {$this->file_path}"); } if( !$this->file_path && file_exists( $this->file_path ) ) unlink( $this->file_path ); return $data; } }