diff --git a/File.php b/File.php index 4fc12d9..8ee2125 100644 --- a/File.php +++ b/File.php @@ -627,9 +627,11 @@ class File extends \yii\db\ActiveRecord $configs = Config::find()->andWhere(['module' => $this->module])->all(); foreach ($configs as $config) { - if(file_exists($this->getFilePath($config->type, true))) + $oldFile = $this->getFilePath($config->type, true); + if(file_exists($oldFile)) { - $s3->upload($this->getFilePath($config->type), $this->getFilePath($config->type, true)); + $s3->upload($this->getFilePath($config->type), $oldFile); + @unlink($oldFile); } } }