-
Notifications
You must be signed in to change notification settings - Fork 0
/
UploadFile.php
41 lines (33 loc) · 914 Bytes
/
UploadFile.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
<?php
include "MainFunctions.php";
$allowedExts = array("html", "HTML", "Html");
$extension = end(explode(".", $_FILES["file"]["name"]));
if (($_FILES["file"]["size"] < 200000000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
if (file_exists("DB/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
updateDocInDB($db, $_FILES["file"]["name"]);
rename("upload/".$_FILES["file"]["name"], "DB/".$_FILES["file"]["name"]);
echo '<br/><a>The file has been uploaded</a>';
}
}
}
else
{
echo "Invalid file";
}
header( 'Location: http://localhost/TheBigBangTheory/AdminPanel.php?dir=DB' ) ;
?>