-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupload.php
44 lines (41 loc) · 1.32 KB
/
upload.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
<!DOCTYPE html>
<html>
<head>
<title>Upload</title>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="CSS/stylesheet.css" />
<link href="https://fonts.googleapis.com/css?family=Heebo:300" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<?php
session_start();
$username= $_SESSION['login_user'];
if (isset( $_SESSION['login_user'])){
// Grab user data from the database using the user_id
// Let them access the "logged in only" pages
} else {
// Redirect them to the login page
header("Location: login.php");
exit();
}
echo '<div class="back-butt">';
echo '<a href="home.php" class="previous round">‹</a>';
echo '</div>';
echo '<section class="file-load">';
$filename = basename($_FILES['uploadedfile']['name']);
if( !preg_match('/^[\w_\.\-]+$/', $filename)){
echo "Invalid filename";
exit;
}
$full_path=sprintf("/home/stevenlee/Module2Info/uploads/%s/%s", $username, $filename);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $full_path)){
echo "Upload Successful";
}
else{
echo "Upload Failed";
}
echo'</section>';
?>
</body>
</html>