-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustompage.php
More file actions
58 lines (33 loc) · 1.01 KB
/
custompage.php
File metadata and controls
58 lines (33 loc) · 1.01 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
<?php
$allowedEnd = "jpg";
$path = "uploads/images/";
$name = $_FILES["file"]["name"];
$splitData = explode(".", $name);
function generateRandName( $minNum, $maxNum, $stringSize ) {
$newName = "";
for( $startLetter = 0; $startLetter < $stringSize; $startLetter ++ )
$newName .= rand( $minNum, $maxNum);
return $newName;
}
if( sizeof($splitData) != 2 ) {
echo "E_INVALIDTYPESIZE;".sizeof($splitData);
die();
}
$fileEnd = $splitData[1];
$fileFront = $splitData[0];
if ( $fileEnd == $allowedEnd ) {
if ($_FILES["file"]["error"] > 0)
echo "E_FAILED;".$_FILES["file"]["error"];
else {
$name = generateRandName( 0, 99, 10 ).".".$allowedEnd;
if (file_exists($name))
echo "E_DOUBLE;".$name;
else {
move_uploaded_file( $_FILES["file"]["tmp_name"], $path.$name );
echo "index.php?file=".$name;
}
}
}
else
echo "E_INVALIDTYPE;".$fileEnd;
?>