Compare commits

..

4 commits

Author SHA1 Message Date
GeorgNation
b7112238c3 #7 Загрузка файлов в папку uploads
ref #7
2024-07-23 14:25:16 +06:00
GeorgNation
2ec7b5c61a Даже так #7
ref #7
2024-07-23 14:19:39 +06:00
GeorgNation
f90a179608 Предусмотрен новый тип хранилища #7
ref #7
2024-07-23 14:16:32 +06:00
GeorgNation
731ff61d78 Папка для загрузок фото 2024-07-23 14:12:34 +06:00
3 changed files with 37 additions and 19 deletions

View file

@ -38,6 +38,9 @@ class Upload
$cstrong = True;
$filecdn = bin2hex(openssl_random_pseudo_bytes(64, $cstrong)) . '.' . $fileext;
$folder = $location . $filecdn;
if (strtolower (NGALLERY['root']['storage']['type']) == "s3")
{
$s3 = new \Aws\S3\S3Client([
'region' => NGALLERY['root']['storage']['s3']['credentials']['region'],
'version' => NGALLERY['root']['storage']['s3']['credentials']['version'],
@ -58,6 +61,17 @@ class Upload
$this->size = self::human_filesize(filesize($tmpname));
$this->name = $name;
}
else
{
@mkdir ("{$_SERVER['DOCUMENT_ROOT']}/uploads/{$location}");
move_uploaded_file ($tmpname, "{$_SERVER['DOCUMENT_ROOT']}/uploads/{$folder}");
$this->type = $type;
$this->src = "/uploads/{$folder}";
$this->size = self::human_filesize(filesize($tmpname));
$this->name = $name;
}
}
public function getType()
{
return $this->type;

View file

@ -20,6 +20,10 @@ ngallery:
websockets:
messages: ""
storage:
# type: 's3' - загрузка файлов в хранилище S3 (Amazon S3, Cloudflare, MinIO и т.д)
# type: 'server' - загрузка файлов в папку uploads (hardcode)
type: 's3'
s3:
domains:

0
uploads/.gitignore vendored Normal file
View file