-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.php
executable file
·63 lines (42 loc) · 1.37 KB
/
data.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
<?php
error_reporting( 0 );
//configs
//if you wanna to custom your url, you can change it like below
// Example http://rasengan.im/space/
$base = "http://" . $_SERVER[ 'HTTP_HOST' ] . substr( $_SERVER[ 'PHP_SELF' ] , 0 , -8 );
// Maxium File Size (default 2MB)
$size_limit = 2097152;
//target folder address
$targetFolder = "file/";
//allow filetype, please use lowercase
$allowFileType = [ "jpg", "png", "gif", "psd", "orinx", "essencious"];
//keep hacker & cracker away ?
if( empty( $_FILES ) ){ die( "an apple a day keeps the doctor away" ); }
$index = 0;
echo "{";
foreach( $_FILES as $file ){
echo '"file'.$index.'": {';
//check image size
if( $file[ 'size' ] > $size_limit || $file[ 'size' ] == 0 ){
echo '"status": "toolarge"';
}else{
//get file extensions
$fnSp = split( '[.]', $file[ 'name' ] );
$fileType = strtolower( $fnSp[ count( $fnSp ) -1 ] );
$pass = false;
foreach( $allowFileType as $aft ){
if( $aft == $fileType ){
$uid_name = uniqid();
move_uploaded_file( $file[ "tmp_name" ], $targetFolder . $uid_name . "." . $aft );
echo '"status":"success", "link":"' . $base . $targetFolder . $uid_name . '.' . $aft . '"';
$pass = true;
break;
}
}
if( !$pass ){ echo '"status": "filetype_not_support"'; }
}
$index++;
echo "},";
}
echo '"filelen": "' . $index . '"}';
?>