-
Notifications
You must be signed in to change notification settings - Fork 18
/
edit_image.php
31 lines (26 loc) · 935 Bytes
/
edit_image.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
session_start();
require('config/config.php');
require('model/functions.fn.php');
if(isset($_FILES['image']) && !empty($_FILES['image'])){
$file = $_FILES['image']['name'];
$file_tmp = $_FILES['image']['tmp_name'];
$nom = '';
$resultat = false;
if (is_file($file_tmp)){
$extension_upload = strtolower(substr( strrchr($_FILES['image']['name'], '.') ,1));
if (preg_match('/\.(png|jpe?g|gif)$/i', $file)) {
$nom = md5(uniqid(rand(), true));
$nom = "view/profil_pic/{$nom}.{$_SESSION['id']}.{$extension_upload}";
$resultat = move_uploaded_file($_FILES['image']['tmp_name'],$nom);
$_SESSION['image'] = $nom;
$register_picture = updateProfilPicture($db, $nom, $_SESSION['id']);
header('Location: dashboard.php');
} else {
echo 'Erreur, le fichier n\'est pas une image !';
}
}
}
include 'view/_header.php';
include 'view/edit_image.php';
include 'view/_footer.php';