Commit dcf8831a authored by Shakarim Sapa's avatar Shakarim Sapa

- Добавили предварительное удаление старого файла

parent fd62688f
......@@ -68,6 +68,9 @@ class AnalyticsSchoolCourse extends \common\components\ActiveRecordModel
// Если валидация неуспешная, возвращаем false
return false;
// Удалили старый файл перед загрузкой нового
$this->deleteFile();
// Сгенерировали путь к папке
$dirname = Yii::$app->security->generateRandomString(5);
// Определили mime тип файла и занесли его в массив
......@@ -97,9 +100,17 @@ class AnalyticsSchoolCourse extends \common\components\ActiveRecordModel
if (!parent::beforeDelete())
return false;
$this->deleteFile();
return true;
}
/**
* @return bool
*/
public function deleteFile(){
$filepath = Yii::getAlias('@frontend').$this->image;
if (file_exists($filepath)) {
unlink($filepath);
return unlink($filepath);
}
return true;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment