Advertisement
Guest User

http-post-example-script.php

a guest
May 8th, 2015
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. <?php
  2.  
  3. $firstName = $_POST["firstName"];
  4. $lastName = $_POST["lastName"];
  5. $userId = $_POST["userId"];
  6. $target_dir = "wp-content/uploads/2015/02";
  7.  
  8. if(!file_exists($target_dir))
  9. {
  10. mkdir($target_dir, 0777, true);
  11. }
  12.  
  13. $target_dir = $target_dir . "/" . basename($_FILES["file"]["name"]);
  14.  
  15. if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_dir)) {
  16. echo json_encode([
  17. "Message" => "The file ". basename( $_FILES["file"]["name"]). " has been uploaded.",
  18. "Status" => "OK",
  19. "userId" => $_REQUEST["userId"]
  20. ]);
  21.  
  22. } else {
  23.  
  24. echo json_encode([
  25. "Message" => "Sorry, there was an error uploading your file.",
  26. "Status" => "Error",
  27. "userId" => $_REQUEST["userId"]
  28. ]);
  29. }
  30.  
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement