-
Notifications
You must be signed in to change notification settings - Fork 0
/
photos.php
100 lines (67 loc) · 2.54 KB
/
photos.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php include('header.php'); ?>
<?php include('session.php'); ?>
<body>
<?php include('navbar.php'); ?>
<div id="masthead">
<div class="container">
<?php include('heading.php'); ?>
</div><!-- /cont -->
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="top-spacer"> </div>
</div>
</div>
</div><!-- /cont -->
</div>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="panel">
<div class="panel-body">
<h2 id="po">My Photos</h2>
<div class="pull-right">
<form id="photos" method="POST" enctype="multipart/form-data">
<label class="control-label" for="input01">Image:</label>
<input type="file" name="image" class="font" required>
<button type="submit" name="submit" class="btn btn-success"><i class="icon-upload"></i> Upload</button>
</form>
<?php
if (isset($_POST['submit'])) {
$image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_name = addslashes($_FILES['image']['name']);
$image_size = getimagesize($_FILES['image']['tmp_name']);
move_uploaded_file($_FILES["image"]["tmp_name"], "upload/" . $_FILES["image"]["name"]);
$location = "upload/" . $_FILES["image"]["name"];
$conn->query("insert into photos (location,user_id) values ('$location','$session_id')");
?>
<script>
window.location = 'photos.php';
</script>
<?php
}
?>
</div>
<div class="row">
<hr>
<hr>
<?php
$query = $conn->query("select * from photos where user_id='$session_id'");
while($row =mysqli_fetch_assoc($query)){
$id = $row['photos_id'];
?>
<div class="col-md-2 col-sm-3 text-center">
<img class="photo" src="<?php echo $row['location']; ?>" width="160" height="150">
<hr>
<a class="btn btn-danger" href="delete_photos.php<?php echo '?id='.$id; ?>"><i class="icon-remove"></i> Delete</a>
</div>
<?php } ?>
</div>
<hr>
</div>
</div>
</div><!--/col-12-->
</div>
</div>
</body>
</html>