Update file compte.php
This commit is contained in:
parent
17796eb96a
commit
7c21a66673
@ -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) {
|
if (isset($_FILES['profile_picture']) && $_FILES['profile_picture']['error'] == 0) {
|
||||||
// Chemins et noms de fichiers
|
// Chemins et noms de fichiers
|
||||||
$tempPath = $_FILES['profile_picture']['tmp_name'];
|
$tempPath = $_FILES['profile_picture']['tmp_name'];
|
||||||
$path = 'src/pp/'. $_SESSION['userid'] .'.png';
|
$path = '/src/pp/'. $_SESSION['userid'] .'.png';
|
||||||
$finalPath = $wwwroot . $path;
|
$rootPath = $wwwroot . $path;
|
||||||
|
$webPath = $root . $path;
|
||||||
|
|
||||||
// Redimensionnement de l'image
|
// Redimensionnement de l'image
|
||||||
$newWidth = 128;
|
$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);
|
imagecopyresampled($imageResized, $imageOriginal, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
|
||||||
|
|
||||||
// Enregistrement de l'image redimensionnée
|
// Enregistrement de l'image redimensionnée
|
||||||
imagepng($imageResized, $finalPath);
|
imagepng($imageResized, $rootPath);
|
||||||
|
|
||||||
// Nettoyage
|
// Nettoyage
|
||||||
imagedestroy($imageOriginal);
|
imagedestroy($imageOriginal);
|
||||||
@ -68,7 +69,7 @@ if (isset($_FILES['profile_picture']) && $_FILES['profile_picture']['error'] ==
|
|||||||
|
|
||||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||||
$req = $bdd->prepare("UPDATE users SET profile_picture = :user_pp WHERE ID = :user_id");
|
$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']);
|
$req->bindParam(":user_id", $_SESSION['userid']);
|
||||||
if($req->execute()) {
|
if($req->execute()) {
|
||||||
$status = "PP mise à jour";
|
$status = "PP mise à jour";
|
||||||
@ -81,7 +82,8 @@ if (isset($_FILES['banner']) && $_FILES['banner']['error'] == 0) {
|
|||||||
// Chemins et noms de fichiers
|
// Chemins et noms de fichiers
|
||||||
$tempPath = $_FILES['banner']['tmp_name'];
|
$tempPath = $_FILES['banner']['tmp_name'];
|
||||||
$path = 'src/pp/'. $_SESSION['userid'] .'.png';
|
$path = 'src/pp/'. $_SESSION['userid'] .'.png';
|
||||||
$finalPath = $wwwroot . $path;
|
$rootPath = $wwwroot . $path;
|
||||||
|
$webPath = $root . $path;
|
||||||
|
|
||||||
// Redimensionnement de l'image
|
// Redimensionnement de l'image
|
||||||
list($width, $height) = getimagesize($tempPath);
|
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);
|
imagecopyresampled($imageResized, $imageOriginal, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
|
||||||
|
|
||||||
// Enregistrement de l'image redimensionnée
|
// Enregistrement de l'image redimensionnée
|
||||||
imagepng($imageResized, $finalPath);
|
imagepng($imageResized, $rootPath);
|
||||||
|
|
||||||
// Nettoyage
|
// Nettoyage
|
||||||
imagedestroy($imageOriginal);
|
imagedestroy($imageOriginal);
|
||||||
@ -100,7 +102,7 @@ if (isset($_FILES['banner']) && $_FILES['banner']['error'] == 0) {
|
|||||||
|
|
||||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||||
$req = $bdd->prepare("UPDATE users SET banner = :user_banner WHERE ID = :user_id");
|
$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']);
|
$req->bindParam(":user_id", $_SESSION['userid']);
|
||||||
if($req->execute()) {
|
if($req->execute()) {
|
||||||
$status = "Banière mise à jour";
|
$status = "Banière mise à jour";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user