· 7 years ago · Aug 21, 2018, 08:48 PM
1<?php
2$secret_key = "imagehosting"; //Set this as your secret key, to prevent others uploading to your server.
3$sharexdir = "i/"; //This is your file dir, also the link..
4$domain_url = 'http://squeezebox.xyz/';
5$lengthofstring = 5; //Length of the file name
6
7function RandomString($length) {
8 $keys = array_merge(range(0,9), range('a', 'z'));
9
10 for($i=0; $i < $length; $i++) {
11 $key .= $keys[mt_rand(0, count($keys) - 1)];
12 }
13 return $key;
14}
15
16if(isset($_POST['secret']))
17{
18 if($_POST['secret'] == $secret_key)
19 {
20 $filename = RandomString($lengthofstring);
21 $target_file = $_FILES["sharex"]["name"];
22 $fileType = pathinfo($target_file, PATHINFO_EXTENSION);
23
24 if (move_uploaded_file($_FILES["sharex"]["tmp_name"], $sharexdir.$filename.'.'.$fileType))
25 {
26 echo $domain_url.$sharexdir.$filename.'.'.$fileType;
27 }
28 else
29 {
30 echo 'File upload failed - CHMOD/Folder doesn\'t exist?';
31 }
32 }
33 else
34 {
35 echo 'Invalid Secret Key';
36 }
37}
38else
39{
40 echo 'No post data recieved';
41}
42?>