-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.php
40 lines (39 loc) · 1.21 KB
/
test.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
<!DOCTYPE html>
<!--
Project by Tanmoy Sen Gupta | tanmoysps@gmail.com | www.tanmoysg.com
-->
<!DOCTYPE html>
<html>
<head>
<title>Upload your files</title>
</head>
<body>
<form enctype="multipart/form-data" action="test.php" method="POST">
<p>Upload your file</p>
<input type="file" name="uploaded_file"><br />
<input type="submit" value="Upload">
</form>
</body>
</html>
<?PHP
include 'connection.php';
session_start();
if (isset($_SESSION['logged_in'])) {
$email = $_SESSION['email'];
$query = "SELECT * FROM users WHERE email ='$email'";
$result = mysqli_query($db, $query);
$row = mysqli_fetch_assoc($result);
$mln = $row['mln'];
if (!empty($_FILES['uploaded_file'])) {
$path = $mln . "/";
echo $path;
$path = $path . basename($_FILES['uploaded_file']['name']);
if (move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $path)) {
echo "The file " . basename($_FILES['uploaded_file']['name']) .
" has been uploaded";
} else {
echo "There was an error uploading the file, please try again!";
}
}
}
?>