How to add in the DB the name of your file in Yii2?

Download file. Controller wrote:
$model->file = UploadedFile::getInstance($model, 'file');
 if($model->uploadFile()) {
return;
 }

In the photo above:
public function uploadFile() {
 if ($model->validate()) {
 $path = Yii::getAlias('@webroot/upload/global/books/');
$model->file->saveAs($path.$model->file->baseName.'.'.$model->file->extension);
return;
 } else { return false; }
 }

The file is successfully loaded, but for some reason Russian letters on krakozyabry change. Someone tell me?
How to add database in the field "file"the name of your file?
July 2nd 19 at 13:50
1 answer
July 2nd 19 at 13:52
tell RV how did they fix the bugs
I krokozyabra was not cleaned, I'm just using generateRandomString() generate random file name - immanuel_West84 commented on July 2nd 19 at 13:55
: op, thank you. good reshenie) and a piece of code will not help with loading form file vzaimodeistvie with this randomized, I don't understand how downloading a file soprach with entering the file name in the dB... - Clovis60 commented on July 2nd 19 at 13:58
: It is in the model
$ext = end((explode(".", $this->bookfile->name)));
$this->bookfile = Yii::$app->security->generateRandomString().".{$ext}";
$path = Yii::getAlias('@webroot').'/upload/global/books/'.$this->bookfile;
$this->bookfile->saveAs(); - immanuel_West84 commented on July 2nd 19 at 14:01
bookfile is my field - immanuel_West84 commented on July 2nd 19 at 14:04

Find more questions by tags PHPYii