-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload.php
More file actions
89 lines (83 loc) · 1.93 KB
/
Copy pathupload.php
File metadata and controls
89 lines (83 loc) · 1.93 KB
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
<?php session_set_cookie_params (0); session_start(); ?>
<?php
if ($_SESSION['course'] == 'cs46')
{
$file_limit = 256 * 1024 * 1024;
}
else if ($_SESSION['course'] == 'cs16')
{
$file_limit = 16 * 1024 * 1024;
}
else
{
$file_limit = 2 * 1024 * 1024;
}
$error = "";
if($_FILES['thefile']['name'] != "")
{
if (strtolower($_FILES['thefile']['name']) == strtolower($_SESSION['fname']))
{
if (is_uploaded_file($_FILES['thefile']['tmp_name']))
{
// if the file is clean, move it to final location
if(file_exists($_FILES['thefile']['tmp_name']))
{
// check the size of the file
if($_FILES['thefile']['size'] < $file_limit)
{
$target_path = "holding/";
$target_path = $target_path . basename( $_FILES['thefile']['tmp_name']);
if(!copy($_FILES['thefile']['tmp_name'], $target_path))
{
$error = "Internal copying error";
}
else
{
$NAME = $_SESSION['fname'];
exec ("./wrap.pl submit "
. $_SESSION['course'] . " " . $_SESSION['assn'] . " "
. "w" . $_SESSION['idnum'] . " " . $target_path . " "
. $NAME, &$result);
if ($result[0] == "Ok")
$_SESSION['success_msg'] = "Successfully uploaded <span class='code'>$NAME</span> for " . strtoupper($_SESSION['assn']);
else
$error = "Internal: $result[0]";
}
}
else
{
$error = "File exceeded size limit";
}
}
else
{
$error = "Internal upload error";
}
}
else
{
$error = "File security error";
}
}
else
{
$error = "File provided doesn't match the requested filename '" .
$_SESSION['fname'] ."'";
}
}
else
{
$error = "No file given";
}
if ($error != "")
$_SESSION['submit_error'] = "Upload failed: $error";
//if ($error == "")
// {
// header ("Location: upload2.php");
// }
//else
// {
$_SESSION['atassignments'] = 1;
header("Location: main.php");
// }
?>