Update file compte.php
This commit is contained in:
parent
6f6b5df137
commit
a5f02d7c3e
@ -55,30 +55,36 @@ if (isset($_FILES['profile_picture']) && $_FILES['profile_picture']['error'] ==
|
|||||||
|
|
||||||
// Redimensionnement de l'image
|
// Redimensionnement de l'image
|
||||||
list($width, $height) = getimagesize($tempPath);
|
list($width, $height) = getimagesize($tempPath);
|
||||||
|
|
||||||
$newWidth = 128;
|
|
||||||
$newHeight = 128;
|
|
||||||
$imageResized = imagecreatetruecolor($newWidth, $newHeight);
|
|
||||||
$imageOriginal = imagecreatefromstring(file_get_contents($tempPath));
|
|
||||||
imagecopyresampled($imageResized, $imageOriginal, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
|
|
||||||
imagealphablending($imageResized, false);
|
|
||||||
imagesavealpha($imageResized, true);
|
|
||||||
|
|
||||||
// Enregistrement de l'image redimensionnée
|
$imageInfo = getimagesize($tempPath);
|
||||||
imagepng($imageResized, $rootPath);
|
|
||||||
|
|
||||||
// Nettoyage
|
if ($imageInfo[2] === IMAGETYPE_PNG || $imageInfo[2] === IMAGETYPE_JPEG) {
|
||||||
imagedestroy($imageOriginal);
|
$newWidth = 128;
|
||||||
imagedestroy($imageResized);
|
$newHeight = 128;
|
||||||
|
$imageResized = imagecreatetruecolor($newWidth, $newHeight);
|
||||||
|
$imageOriginal = imagecreatefromstring(file_get_contents($tempPath));
|
||||||
|
imagecopyresampled($imageResized, $imageOriginal, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
|
||||||
|
imagealphablending($imageResized, false);
|
||||||
|
imagesavealpha($imageResized, true);
|
||||||
|
|
||||||
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
// Enregistrement de l'image redimensionnée
|
||||||
$req = $bdd->prepare("UPDATE users SET profile_picture = :user_pp WHERE ID = :user_id");
|
imagepng($imageResized, $rootPath);
|
||||||
$req->bindParam(":user_pp", $webPath);
|
|
||||||
$req->bindParam(":user_id", $_SESSION['userid']);
|
// Nettoyage
|
||||||
if($req->execute()) {
|
imagedestroy($imageOriginal);
|
||||||
$status = "PP mise à jour";
|
imagedestroy($imageResized);
|
||||||
|
|
||||||
|
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||||
|
$req = $bdd->prepare("UPDATE users SET profile_picture = :user_pp WHERE ID = :user_id");
|
||||||
|
$req->bindParam(":user_pp", $webPath);
|
||||||
|
$req->bindParam(":user_id", $_SESSION['userid']);
|
||||||
|
if($req->execute()) {
|
||||||
|
$status = "PP mise à jour";
|
||||||
|
} else {
|
||||||
|
$status = "Erreur SQL";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$status = "Erreur SQL";
|
$status = "Le fichier doit être au format PNG ou JPG";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +97,9 @@ if (isset($_FILES['banner']) && $_FILES['banner']['error'] == 0) {
|
|||||||
|
|
||||||
// Redimensionnement de l'image
|
// Redimensionnement de l'image
|
||||||
list($width, $height) = getimagesize($tempPath);
|
list($width, $height) = getimagesize($tempPath);
|
||||||
|
$imageInfo = getimagesize($tempPath);
|
||||||
|
|
||||||
|
if ($imageInfo[2] === IMAGETYPE_PNG || $imageInfo[2] === IMAGETYPE_JPEG) {
|
||||||
$newWidth = 800;
|
$newWidth = 800;
|
||||||
$newHeight = ($height / $width) * $newWidth;
|
$newHeight = ($height / $width) * $newWidth;
|
||||||
$imageResized = imagecreatetruecolor($newWidth, $newHeight);
|
$imageResized = imagecreatetruecolor($newWidth, $newHeight);
|
||||||
@ -115,6 +124,9 @@ if (isset($_FILES['banner']) && $_FILES['banner']['error'] == 0) {
|
|||||||
} else {
|
} else {
|
||||||
$status = "Erreur SQL";
|
$status = "Erreur SQL";
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$status = "Le fichier doit être un PNG ou JPG"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user