-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathupfile.php
64 lines (55 loc) · 1.78 KB
/
upfile.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
include ('../../inc/includes.php');
Session::checkLoginUser();
$plugin = new Plugin();
if ($plugin->isActivated("mod")) {
//if they DID upload a file...
if($_FILES['photo']['name'])
{
//if no errors...
if(!$_FILES['photo']['error'])
{
//now is the time to modify the future file name and validate the file
$new_file_name = strtolower($_FILES['photo']['name']); //rename file
$info = getimagesize($_FILES['photo']['tmp_name']);
if($_FILES['photo']['size'] > (10240000)) //can't be larger than 10 MB
{
$valid_file = false;
$message = 'Oops! Your file\'s size is to large.';
}
elseif($info === false) {
$valid_file = false;
die("Unable to determine image type of uploaded file");
}
else { $valid_file = true; }
//if the file has passed the test
if($valid_file)
{
//move it to where we want it to be
$currentdir = getcwd();
$target = '../../pics/bg/' . basename($_FILES['photo']['name']);
//$target = $currentdir .'/uploads/' . basename($_FILES['photo']['name']);
move_uploaded_file($_FILES['photo']['tmp_name'], $target);
//move_uploaded_file($_FILES['photo']['tmp_name'], 'uploads'.$new_file_name);
rename('../../pics/bg/'.basename($_FILES['photo']['name']), '../../pics/bg/back.jpg');
$message = 'Congratulations! Your file was accepted.';
header('Location: ../../plugins/mod/config.php ');
//echo $message;
}
}
//if there is an error...
else
{
//set that to be the returned message
header('Location: ../../plugins/mod/config.php ');
$message = 'Ooops! Your upload triggered the following error: '.$_FILES['photo']['error'];
echo $message;
}
}
else
{
//set that to be the returned message
header('Location: ../../plugins/mod/config.php ');
}
}
?>