Advertisement
Guest User

Untitled

a guest
Oct 30th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <?php
  2.  
  3. $response = "Upload failed";
  4.  
  5. if(isset($_POST['usrIMG']) && isset($_POST['usrID']))
  6. {
  7. $now = DateTime::createFromFormat('U.u',microtime(true));
  8. $id = $now->format('YmdHisu');
  9.  
  10. $upload_folder = "Uploads";
  11. $usrID = $_POST['usrID'];
  12. $usrIMG = $_POST['usrIMG'];
  13. $path = "$upload_folder/$usrID/$id.jpeg";
  14. if (!file_exists("$upload_folder/$usrID/"))
  15. {
  16. mkdir("$upload_folder/$usrID/", 0777, true);
  17. }
  18.  
  19. $dbhost = 'localhost';
  20. $dbname = 'dressoff';
  21. $dbuser = 'root';
  22. $dbpass = '134679';
  23.  
  24. $pdo_info = "mysql:host=$dbhost;dbname=$dbname";
  25. $conn = new PDO($pdo_info, $dbuser, $dbpass);
  26.  
  27. $check = $conn->prepare("INSERT INTO uploads VALUES(?,?)");
  28. $check->bindParam(1, $_POST['usrID']);
  29. $check->bindParam(2, $usrID);
  30.  
  31.  
  32. if($check->execute() && file_put_contents($path,base64_decode($usrIMG)) != false)
  33. {
  34. $response = "Upload succeed";
  35. }
  36. }
  37.  
  38. echo $response;
  39.  
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement