Bổ sung các tính năng điều khiển engine

This commit is contained in:
2023-09-21 14:46:52 +07:00
parent d8fe80034e
commit 6ae14302fd
18 changed files with 570 additions and 44 deletions

View File

@@ -131,6 +131,33 @@ class UploadForm extends Model {
}
}
public function UploadSound($file, $fileTypes, $path) {
$root = \Yii::getAlias('@app') . '/web/data';
$LocalPath = "/" . $path;
$RootFolder = $root . $LocalPath;
$destfile = "welcome_en.wav";
if (!empty($_FILES)) {
$tempFile = $_FILES[$file]['tmp_name'];
$targetPath = $RootFolder;
if (!file_exists($targetPath)) {
@mkdir($targetPath, 0777, true);
}
$targetFile = $targetPath . '/' . $destfile;
$targetFileLocal = $LocalPath . '/' . $destfile;
$fileParts = pathinfo($_FILES[$file]['name']);
if (in_array(strtoupper($fileParts['extension']), $fileTypes)) {
move_uploaded_file($tempFile, $targetFile);
if (file_exists($targetFile)) {
return $targetFileLocal;
} else {
return false;
}
} else {
return 2;
}
}
}
//Move file
public function MoveFile($file, $folder) {
$currentStorage = Storage::findOne(['stt' => 1])->folder;