/**
  * Action to replace a current file with a new.
  *
  * @return boolean
  */
 public function actionFileReplace()
 {
     $fileId = Yii::$app->request->post('fileId', false);
     $raw = $_FILES['file'];
     /** @var $file \luya\admin\file\Item */
     if ($file = Yii::$app->storage->getFile($fileId)) {
         $serverSource = $file->getServerSource();
         if (is_uploaded_file($raw['tmp_name'])) {
             if (Storage::replaceFile($serverSource, $raw['tmp_name'])) {
                 foreach (Yii::$app->storage->findImages(['file_id' => $file->id]) as $img) {
                     Storage::removeImage($img->id, false);
                 }
                 return true;
             }
         }
     }
     return false;
 }
 public function callbackRemove($imageId)
 {
     $image = Yii::$app->storage->getImage($imageId);
     if ($image) {
         $this->modelItem->flowDeleteImage($image);
         if (Storage::removeImage($image->id, true)) {
             return $this->sendSuccess('image has been removed');
         }
     }
     return $this->sendError('Unable to remove this image');
 }