Update file compte.php

This commit is contained in:
Jan BELLON 2024-03-12 09:01:12 +00:00
parent 17796eb96a
commit 7c21a66673

View File

@ -49,8 +49,9 @@ if(isset($_POST['user_display_name']) && isset($_POST['user_name']) && isset($_P
if (isset($_FILES['profile_picture']) && $_FILES['profile_picture']['error'] == 0) {
// Chemins et noms de fichiers
$tempPath = $_FILES['profile_picture']['tmp_name'];
$path = 'src/pp/'. $_SESSION['userid'] .'.png';
$finalPath = $wwwroot . $path;
$path = '/src/pp/'. $_SESSION['userid'] .'.png';
$rootPath = $wwwroot . $path;
$webPath = $root . $path;
// Redimensionnement de l'image
$newWidth = 128;
@ -60,7 +61,7 @@ if (isset($_FILES['profile_picture']) && $_FILES['profile_picture']['error'] ==
imagecopyresampled($imageResized, $imageOriginal, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
// Enregistrement de l'image redimensionnée
imagepng($imageResized, $finalPath);
imagepng($imageResized, $rootPath);
// Nettoyage
imagedestroy($imageOriginal);
@ -68,7 +69,7 @@ if (isset($_FILES['profile_picture']) && $_FILES['profile_picture']['error'] ==
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
$req = $bdd->prepare("UPDATE users SET profile_picture = :user_pp WHERE ID = :user_id");
$req->bindParam(":user_pp", $path);
$req->bindParam(":user_pp", $webPath);
$req->bindParam(":user_id", $_SESSION['userid']);
if($req->execute()) {
$status = "PP mise à jour";
@ -81,7 +82,8 @@ if (isset($_FILES['banner']) && $_FILES['banner']['error'] == 0) {
// Chemins et noms de fichiers
$tempPath = $_FILES['banner']['tmp_name'];
$path = 'src/pp/'. $_SESSION['userid'] .'.png';
$finalPath = $wwwroot . $path;
$rootPath = $wwwroot . $path;
$webPath = $root . $path;
// Redimensionnement de l'image
list($width, $height) = getimagesize($tempPath);
@ -92,7 +94,7 @@ if (isset($_FILES['banner']) && $_FILES['banner']['error'] == 0) {
imagecopyresampled($imageResized, $imageOriginal, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
// Enregistrement de l'image redimensionnée
imagepng($imageResized, $finalPath);
imagepng($imageResized, $rootPath);
// Nettoyage
imagedestroy($imageOriginal);
@ -100,7 +102,7 @@ if (isset($_FILES['banner']) && $_FILES['banner']['error'] == 0) {
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
$req = $bdd->prepare("UPDATE users SET banner = :user_banner WHERE ID = :user_id");
$req->bindParam(":user_banner", $path);
$req->bindParam(":user_banner", $webPath);
$req->bindParam(":user_id", $_SESSION['userid']);
if($req->execute()) {
$status = "Banière mise à jour";