fix languages

This commit is contained in:
Dennis Eichhorn 2021-02-07 15:03:40 +01:00
parent fd1b8b7d5f
commit 98942d585f
2 changed files with 16 additions and 2 deletions

View File

@ -140,6 +140,19 @@ final class ApiController extends Controller
return $this->createDbEntries($status, $account, $virtualPath, $type);
}
public static function uploadFilesToDestination(
array $files,
string $name = '',
string $path = '',
) : array {
$upload = new UploadFile();
$upload->setOutputDir($path);
$status = $upload->upload($files, $name, true, '');
return $status;
}
/**
* Create a random file path to store media files
*

View File

@ -118,7 +118,7 @@ class UploadFile
$this->outputDir = $this->findOutputDir();
}
$path = $this->outputDir;
$path = empty($this->outputDir) ? $f['tmp_name'] : $this->outputDir;
foreach ($files as $key => $f) {
$result[$key] = [];
@ -158,6 +158,7 @@ class UploadFile
$result[$key]['filename'] = $this->fileName;
}
// @todo: find a way to allow upload to default temp directory, maybe check if $path is empty, if empty don't change directory, just keep it in the temp directory
if (empty($this->fileName) || \is_file($path . '/' . $this->fileName)) {
try {
$this->fileName = $this->createFileName($path, $f['tmp_name'], $extension);
@ -222,7 +223,7 @@ class UploadFile
//FileUtils::changeFileEncoding($dest, $encoding);
}*/
$result[$key]['path'] = \realpath($this->outputDir);
$result[$key]['path'] = $this->outputDir === '' ? $f['tmp_name'] : \realpath($this->outputDir);
}
return $result;