= 94371840) { mkdir("{$_SERVER['DOCUMENT_ROOT']}/uploads/{$location}", 0777, true); 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; return; } } } $s3 = new \Aws\S3\S3Client([ 'region' => NGALLERY['root']['storage']['s3']['credentials']['region'], 'version' => NGALLERY['root']['storage']['s3']['credentials']['version'], 'credentials' => [ 'key' => NGALLERY['root']['storage']['s3']['credentials']['key'], 'secret' => NGALLERY['root']['storage']['s3']['credentials']['secret'], ], 'endpoint' => NGALLERY['root']['storage']['s3']['domains']['gateway'], ]); $s3->putObject([ 'Bucket' => NGALLERY['root']['storage']['s3']['credentials']['bucket'], 'Key' => $location.$filecdn, 'SourceFile' => $tmpname ]); $this->type = $type; $this->src = NGALLERY['root']['storage']['s3']['domains']['public'] . '/' . $location . $filecdn; $this->size = self::human_filesize(filesize($tmpname)); $this->name = $name; } else { echo $tmpname; $location = "your-location"; // Название локации $folder = "{$location}/" . basename($tmpname); // Создаем корректное имя для папки с файлом $uploadDir = "{$_SERVER['DOCUMENT_ROOT']}/uploads/{$location}"; // Полный путь к директории // Создание директории, если она не существует if (!is_dir($uploadDir)) { mkdir($uploadDir, 0777, true); } // Путь к файлу, куда он должен быть перемещен $destination = "{$uploadDir}/" . basename($tmpname); // Перемещение файла if (move_uploaded_file($tmpname, $destination)) { echo "Файл успешно перемещен!"; } else { echo "Ошибка при перемещении файла."; } $this->type = $type; $this->src = "/uploads/{$folder}"; $this->size = self::human_filesize(filesize($tmpname)); $this->name = $name; } } public function getType() { return $this->type; } public function getSrc() { return $this->src; } public function getSize() { return $this->size; } public function getName() { return $this->name; } }