/**
  * Uploads file.
  * @param string $attr Owner model attribute name.
  * @return array json response.
  */
 public function run($attr)
 {
     \Yii::$app->response->format = Response::FORMAT_JSON;
     $model = new File();
     $model->setAttributes(['ownerAttribute' => $attr, 'uploadUrl' => $this->uploadUrl, 'uploadPath' => $this->uploadPath, 'permissions' => $this->permissions, 'customRules' => $this->customRules, 'file' => UploadedFile::getInstanceByName('file')], false);
     return $model->validate() ? ['filelink' => $model->getDirUrl() . $model->getFileName(), "filename" => $model->getFileName()] : $this->error($model->firstErrors);
 }