forked from daattali/beautiful-jekyll
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathup.php
43 lines (39 loc) · 1.21 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
<?php
$secret_key = "S9FeruzUFiTLNyQMukHxrhh4F6UPgcFeu5s886dbkg4XNbHdeLNjvnaMSx6LFMuN"; //Set this as your secret key, to prevent others uploading to your server.
$sharexdir = "img/"; //This is your file dir, also the link..
$domain_url = 'https://idleanimation.com'; //Add an S at the end of HTTP if you have a SSL certificate.
$lengthofstring = 5; //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["sharex"]["name"];
$fileType = pathinfo($target_file, PATHINFO_EXTENSION);
if (move_uploaded_file($_FILES["sharex"]["tmp_name"], $sharexdir.$filename.'.'.$fileType))
{
echo $domain_url.$sharexdir.$filename.'.'.$fileType;
}
else
{
echo 'File upload failed - CHMOD/Folder doesn\'t exist?';
}
}
else
{
echo 'Invalid Secret Key';
}
}
else
{
echo 'No post data recieved';
}
?>