Commit 92fb47d2 authored by Shakarim Sapa's avatar Shakarim Sapa

- Изменен алгоритм формирования пути для сохранения файла

parent bb22ac31
...@@ -68,8 +68,9 @@ class AnalyticsSchoolCourse extends \common\components\ActiveRecordModel ...@@ -68,8 +68,9 @@ class AnalyticsSchoolCourse extends \common\components\ActiveRecordModel
// Если валидация неуспешная, возвращаем false // Если валидация неуспешная, возвращаем false
return false; return false;
// Удалили старый файл перед загрузкой нового if (!is_null($this->image))
$this->deleteFile(); // Удалили старый файл перед загрузкой нового
$this->deleteFile();
// Сгенерировали путь к папке // Сгенерировали путь к папке
$dirname = Yii::$app->security->generateRandomString(5); $dirname = Yii::$app->security->generateRandomString(5);
...@@ -108,7 +109,7 @@ class AnalyticsSchoolCourse extends \common\components\ActiveRecordModel ...@@ -108,7 +109,7 @@ class AnalyticsSchoolCourse extends \common\components\ActiveRecordModel
* @return bool * @return bool
*/ */
public function deleteFile(){ public function deleteFile(){
$filepath = Yii::getAlias('@frontend').DIRECTORY_SEPARATOR.'web'.$this->image; $filepath = Yii::getAlias('@frontend').'/'.'web'.$this->image;
if (file_exists($filepath)) { if (file_exists($filepath)) {
return unlink($filepath); return unlink($filepath);
} }
......
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