-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_photo.php
38 lines (30 loc) · 1.02 KB
/
add_photo.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
<?php
include('includes/database.php');
include('session.php');
if (!isset($_FILES['image']['tmp_name'])) {
echo "";
}else{
$file=$_FILES['image']['tmp_name'];
$image = $_FILES["image"] ["name"];
$image_name= addslashes($_FILES['image']['name']);
$size = $_FILES["image"] ["size"];
$error = $_FILES["image"] ["error"];
if ($error > 0){
echo "<script>alert('No Photo Attached!'); window.location='photos.php'</script>";
}else{
if($size > 10000000) //conditions for the file
{
echo "<script>alert('Invalid Photo Format!'); window.location='photos.php'</script>";
}
else
{
move_uploaded_file($_FILES["image"]["tmp_name"],"upload/" . $_FILES["image"]["name"]);
$location="upload/" . $_FILES["image"]["name"];
$user=$_SESSION['id'];
$update=mysqli_query($con," INSERT INTO photos (location,user_id,date_added)
VALUES ('$location','$id',NOW()) ");
}
header('location:photos.php');
}
}
?>