<?php
include ("inc/db/db.php");
session_start();
if ($stmt = $mysqli->prepare('SELECT `profilbillede` FROM `bruger` WHERE `id` = ?')) {
$stmt->bind_param('i', $id);
$id = $_SESSION["id"];
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($profilbillede);
$UploadDir = "profil-img/"; //ligger i toppen af documentet, evt som en define
if($stmt->fetch()){
$tmpfile = $UploadDir."".$profilbillede;
if(file_exists($tmpfile)) {
unlink($tmpfile);
}
$tmpfile = $UploadDir."lille/".$profilbillede;
if(file_exists($tmpfile)) {
unlink($tmpfile);
}
$tmpfile = $UploadDir."store/".$profilbillede;
if(file_exists($tmpfile)) {
unlink($tmpfile);
}
}
$stmt->close();
} else {
/* Der er opstået en fejl */
echo 'Der opstod en fejl i erklæringen: ' . $mysqli->error;
}
include "inc/img/class.upload.php";
$handle = new Upload($_FILES["filename"]);
if($handle->uploaded)
{
//lidt mere store billeder
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_x = 220;
$handle->Process("profil-img/store");
//til profil billede lign..
$handle->image_resize = true;
$handle->image_ratio_crop = true;
$handle->image_y = 115;
$handle->image_x = 100;
$handle->Process("profil-img");
//til profil billede lign..
$handle->image_resize = true;
$handle->image_ratio_crop = true;
$handle->image_y = 75;
$handle->image_x = 75;
$handle->Process("profil-img/lille");
$pb = $handle->file_dst_name;
}
if ($stmt_u = $mysqli->prepare('UPDATE `bruger` SET `profilbillede`=?, `profilbillede_godkendt`=? WHERE `id`=?')) {
/* Bind parametre */
$stmt_u->bind_param('ssi', $profilbillede, $profilbillede_godkendt, $id);
/* Sæt værdier på parametrene */
$profilbillede = $pb;
$profilbillede_godkendt = '0';
$id = $_SESSION["id"];
/* Eksekver forespørgslen */
$stmt_u->execute();
/* Luk statement */
$stmt_u->close();
header('Location:
http://www......dk/indstillinger-bruger/');
} else {
/* Der er opstået en fejl */
echo 'Der opstod en fejl i erklæringen: ' . $mysqli->error;
}
?>