public function actionGetFile() { $model = new GetFile(); $model->attributes = isset($_POST) ? $_POST : ''; if ($model->validate()) { //validating json data according to action $model->readFile(); } else { echo json_encode($model->getErrors()); } }