-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathup.php
47 lines (44 loc) · 1.09 KB
/
up.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
45
46
47
<?php
$secret_key = "make a key here";
$lengthofstring = 8; //Length of the file name
function RandomString($length) {
$keys = array_merge(range(0,9), range('a', 'z'));
$key = '';
for($i=0; $i < $length; $i++) {
$key .= $keys[mt_rand(0, count($keys) - 1)];
}
return $key;
}
if(isset($_POST['secret']))
{
if($_POST['secret'] == $secret_key)
{
$filename = RandomString($lengthofstring);
$target_file = $_FILES["file"]["name"];
$fileType = pathinfo($target_file, PATHINFO_EXTENSION);
if($fileType == 'txt')
{
if (move_uploaded_file($_FILES["file"]["tmp_name"], 'logs/'.$filename.'.'.$fileType))
{
echo $filename.'.'.$fileType;
}
else
{
echo 'Error: File upload failed - CHMOD/Folder doesn\'t exist?';
}
}
else
{
echo 'Error: File type "'.$fileType.'" is not valid';
}
}
else
{
echo 'Error: Invalid Secret Key';
}
}
else
{
echo 'Error: No post data recieved';
}
?>