-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.php
80 lines (53 loc) · 1.59 KB
/
upload.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<?php
session_start();
//session_destroy();
?>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>EBImage</title>
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>
<body>
<?php
$img_taille = 0;
$img_type = '';
$img_nom = '';
$taille_max = 750000;
$ret = "uploads/" . basename($_FILES["img"]["name"]);
$chemin= "img/".$_FILES['img']['name'];
if(isset($_POST["submit"]))
{
$check = getimagesize($_FILES["img"]["tmp_name"]);
if($check == false)
{
echo "Echec";
}
else
$img_taille = $_FILES['img']['size'];
if ($img_taille > $taille_max)
{
echo "Trop gros !";
}
else
{
$img_nom = $_FILES['img']['tmp_name'];
move_uploaded_file ( $img_nom , $chemin );
echo "<img src='$chemin' > <br>";
// print_r($check);
}
header("Location: index.php");
}
$info = new SplFileInfo($chemin);
$nom = $info->getFilename();
include('connexion.php');
$req = $connexion->prepare('INSERT INTO img_telechargee (chemin_tele,nom_img_tele) VALUES( ?,?)');
$req->execute(array($chemin,$nom));
$_SESSION['cheminTele']=$chemin;
$_SESSION['lastIdtele']=$connexion->lastInsertId();
?>
</body>
</html>