-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathr1r2upl.php
More file actions
49 lines (34 loc) · 1.26 KB
/
Copy pathr1r2upl.php
File metadata and controls
49 lines (34 loc) · 1.26 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
<?php
if(isset($_POST["submitR1R2"])){
$currentDirectory = getcwd();
echo $currentDirectory;
$uploadDirectory = "/uploads/";
$errors = []; // Store errors here
foreach ($_FILES['files']['tmp_name'] as $key => $value) {
$fileName = $_FILES['files']['name'][$key];
$fileSize = $_FILES['files']['size'][$key];
$fileTmpName = $_FILES['files']['tmp_name'][$key];
$fileType = $_FILES['files']['type'][$key];
$fileExtension = strtolower(end(explode('.',$fileName)));
$uploadPath = $currentDirectory . $uploadDirectory . basename($fileName);
if ($fileSize > 4000000) {
$errors[] = "File exceeds maximum size (4MB)";
}
if (empty($errors)) {
$didUpload = move_uploaded_file($fileTmpName, $uploadPath);
if ($didUpload) {
echo "The file " . basename($fileName) . " has been uploaded";
} else {
echo "An error occurred. Please contact the administrator.";
foreach ($errors as $error) {
echo $error . "These are the errors" . "\n";
}
}
} else {
foreach ($errors as $error) {
echo $error . "These are the errors" . "\n";
}
}
}
}
?>