-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost.php
39 lines (31 loc) · 1.05 KB
/
post.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
<?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='home.php'</script>";
}else{
if($size > 10000000) //conditions for the file
{
echo "<script>alert('Invalid Photo Format!'); window.location='home.php'</script>";
}
else{
move_uploaded_file($_FILES["image"]["tmp_name"],"upload/" . $_FILES["image"]["name"]);
$location="upload/" . $_FILES["image"]["name"];
$user=$_SESSION['id'];
$content=$_POST['content'];
$time=time();
$update=mysqli_query($con," INSERT INTO post (user_id,post_image,content,created)
VALUES ('$id','$location','$content','$time') ");
}
header('location:home.php');
}
}
?>