-
+
diff --git a/admin/profile.php b/admin/profile.php
new file mode 100644
index 0000000..c45c783
--- /dev/null
+++ b/admin/profile.php
@@ -0,0 +1,111 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ Профиль пользователя
+
+
+
+
\ No newline at end of file
diff --git a/core/lib/Core/Models/File.class.php b/core/lib/Core/Models/File.class.php
index f96b451..2feccca 100644
--- a/core/lib/Core/Models/File.class.php
+++ b/core/lib/Core/Models/File.class.php
@@ -167,19 +167,28 @@
return end(explode('.', $filename));
}
- public function saveFile(string $filePath, ?string $fileName = null): self
+ public function saveFile(string $filePath, ?string $fileName = null, bool $useMove = false): self
{
- $storageFileName = md5(time() . $fileName . rand(1, 9999)) . '.' . static::getExt($filePath);
- $storageFullPath = $this->folder . '/' . $storageFileName;
+ $storageFileName = md5(time() . $fileName . rand(1, 9999));
if (empty($fileName)) {
- $fileName = $storageFileName;
+ $fileName = $storageFileName . '.' . static::getExt($filePath);
+ $storageFileName .= '.' . static::getExt($filePath);
+ } else {
+ $storageFileName .= '.' . static::getExt($fileName);
}
+ $storageFullPath = $this->folder . '/' . $storageFileName;
- if (!copy($filePath, $storageFullPath)) {
- throw new CoreException('Не удалось скопировать файл', CoreException::ERROR_FILE_COPY);
+ if($useMove) {
+ if (!move_uploaded_file($filePath, $storageFullPath)) {
+ throw new CoreException('Не удалось скопировать загруженный файл', CoreException::ERROR_FILE_COPY);
+ }
+ } else {
+ if (!copy($filePath, $storageFullPath)) {
+ throw new CoreException('Не удалось скопировать файл', CoreException::ERROR_FILE_COPY);
+ }
}
$this->name = $fileName;
- $this->path = $storageFullPath;
+ $this->path = self::FOLDER . '/' . $storageFileName;
$this->id = $this->DB->addItem(self::TABLE, ['name' => $this->name, 'path' => $this->path]);
+
+
+
+ $_POST['name'], 'email' => $_POST['email']];
+ if (isset($_FILES['image']) && $_FILES['image']['error'] === UPLOAD_ERR_OK) {
+ $File = new File();
+ $File->saveFile($_FILES['image']['tmp_name'], $_FILES['image']['name'], true);
+ $newUserFields['image'] = $File->getPath();
+ }
+
+ $USER->update($newUserFields);
+ ?>
+
+
+
+ Профиль успешно обновлен
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = $USER->getName(); ?>
+= $USER->getAllUserData()['date_created']; ?>
+
+
+
+
+