Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. <?php
  2. $secret_key = "9ge9ag99135213tgedavxgfedsaxeg"; //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://domain.com/';
  5. $lengthofstring = 5; //Length of the file name
  6.  
  7. $safe_types = ["jpg", "jpeg", "png", "gif"];
  8.  
  9. function RandomString($length) {
  10.     $keys = array_merge(range(0,9), range('a', 'z'));
  11.  
  12.     for($i=0; $i < $length; $i++) {
  13.         $key .= $keys[mt_rand(0, count($keys) - 1)];
  14.     }
  15.     return $key;
  16. }
  17.  
  18. if(isset($_POST['secret']))
  19. {
  20.     if($_POST['secret'] == $secret_key)
  21.     {
  22.         $filename = RandomString($lengthofstring);
  23.         $target_file = $_FILES["sharex"]["name"];
  24.         $fileType = pathinfo($target_file, PATHINFO_EXTENSION);
  25.         //not sure how save that is, but you can use this instead:
  26.         //$fileType = strtolower(end(explode(".", $target_file)));
  27.         if (in_array($fileType, $safe_types))
  28.         {
  29.             if (move_uploaded_file($_FILES["sharex"]["tmp_name"], $sharexdir.$filename.'.'.$fileType))
  30.             {
  31.                 echo $domain_url.$sharexdir.$filename.'.'.$fileType;
  32.             }
  33.             else
  34.             {
  35.                echo 'File upload failed - CHMOD/Folder doesn\'t exist?';
  36.             }
  37.         }  
  38.     }
  39.     else
  40.     {
  41.         echo 'Invalid Secret Key';
  42.     }
  43. }
  44. else
  45. {
  46.     echo 'No post data recieved';
  47. }