-
Notifications
You must be signed in to change notification settings - Fork 1
/
uploadCOM.php
92 lines (64 loc) · 1.85 KB
/
uploadCOM.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
<?php
session_start();
// Include the database configuration file
require 'connect.php';
require 'functions.php';
require 'header.php';
require 'header2.php';
?>
<!DOCTYPE html>
<html>
<head>
<style>
h3 {
text-align: center;
}
a {
text-align:center;
}
</style>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>
</title>
<link href="main.css" rel="stylesheet">
</head>
<body>
<br><br><br>
<div class="login-form box-center clearfix">
<?php
if(isset($_SESSION['username'], $_SESSION['password'])) {
// If file upload form is submitted
$status = $statusMsg = '';
if (isset($_POST['upload'])) {
if(!is_dir("user/". $_SESSION["username"] ."/")) {
mkdir("user/". $_SESSION["username"] ."/");
}
$filename = $_FILES["uploadfile"]["name"];
$tempname = $_FILES["uploadfile"]["tmp_name"];
$newfilename = 'COM'.date('Y-m-d');
$rename = $newfilename.'.jpeg';
$folder = "user/". $_SESSION["username"] ."/". $rename;
// Get all the submitted data from the form
$sql = "UPDATE documents SET COM= '$rename' WHERE username = '".$_SESSION['username']."' AND password = '".$_SESSION['password']."'";
// Execute query
mysqli_query($con, $sql);
// Now let's move the uploaded user into the folder: user
if (move_uploaded_file($tempname, $folder)) {
echo "<h3> user uploaded successfully!</h3>";
} else {
echo "<h3> Failed to upload user!</h3>";
}
}
// Display status message
echo $statusMsg;
?>
<center><a class="btn btn-secondary" href="profile.php" role="button">Go back</a></center>
<?php
} else {
header("location:index.php");
exit;
}
unset($_SESSION['prompt']);
mysqli_close($con);
?>