upload.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /*
  3. *
  4. * Application Name: PHP Custom Content Uploader
  5. * Module Name: upload.php
  6. *
  7. * Copyright (c) 2020 DBMXPCA Technologies. All rights reserved.
  8. * https://www.dbmxpca.com/
  9. *
  10. */
  11. require_once($_SERVER['DOCUMENT_ROOT'] . "/core.php");
  12. /*
  13. *
  14. * This script is designed to be called with the following parameters:
  15. *
  16. * Parameter Description
  17. * -----------------------------------------------------------------
  18. * u Username, corresponding to the user's name in the "users.json" file. Value may not be empty. Case-sensitive.
  19. * k API Key, corresponding to the user's "key" value in the "users.json" file. Value may not be empty. Not case-sensitive by default but can be changed in "config.php". Not recommended to use as clients seem to send them without proper format.
  20. *
  21. */
  22. // Check user authorization.
  23. $err = null;
  24. if (CHECK_USER($err)){
  25. // Check image prelim data.
  26. $err = null;
  27. if (CHECK_IMAGE_PRELIM_DATA($err)){
  28. $err = null;
  29. if (CHECK_IMAGE_ERRORS($err)){
  30. // Attempt to create user's directory within UCD.
  31. if (CREATE_USER_CONTENT_DIR($_REQUEST['u'])){
  32. //echo "ok";
  33. SAVE_IMAGE($_REQUEST['u'], $_FILES['image']['type'], $_FILES['image']['tmp_name']);
  34. }
  35. else{
  36. $err = "500_1";
  37. DIE_ERR($err);
  38. }
  39. }
  40. else{
  41. DIE_ERR($err);
  42. }
  43. }
  44. else{
  45. DIE_ERR($err);
  46. }
  47. }
  48. else{
  49. DIE_ERR($err);
  50. }