· 5 years ago · Feb 25, 2020, 10:02 AM
1<?php
2
3$secret_key = "9HU79vcxC"; //Set this as your secret key, to prevent others uploading to your server.
4
5$sharexdir = ""; //This is your file dir, also the link..
6
7$domain_url = 'https://screenshots.clement-repel.fr/';
8
9$lengthofstring = 10; //Length of the file name
10
11
12
13function RandomString($length) {
14
15 $keys = array_merge(range(0,9), range('a', 'z'));
16
17
18
19 $key = '';
20
21 for($i=0; $i < $length; $i++) {
22
23 $key .= $keys[mt_rand(0, count($keys) - 1)];
24
25 }
26
27 return $key;
28
29}
30
31
32
33if(isset($_POST['secret']))
34
35{
36
37 if($_POST['secret'] == $secret_key)
38
39 {
40
41 $filename = RandomString($lengthofstring);
42
43 $target_file = $_FILES["sharex"]["name"];
44
45 $fileType = pathinfo($target_file, PATHINFO_EXTENSION);
46
47
48
49 if (move_uploaded_file($_FILES["sharex"]["tmp_name"], $sharexdir.$filename.'.'.$fileType))
50
51 {
52
53 echo $domain_url.$sharexdir.$filename.'.'.$fileType;
54
55 }
56
57 else
58
59 {
60
61 echo 'File upload failed - CHMOD/Folder doesn\'t exist?';
62
63 }
64
65 }
66
67 else
68
69 {
70
71 echo 'Invalid Secret Key';
72
73 }
74
75}
76
77else
78
79{
80
81 echo 'No post data recieved';
82
83}
84
85?>