Simple temporary file hosting https://u.fuwafuwa.moe

api.php 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. //Loading configuration file
  3. require_once "includes/config.php";
  4. //If the value d doesn't exist, redirect back to front page *1
  5. if(isset($_GET['d'])) {
  6. //Include the core file with the functions
  7. include_once(CONFIG_ROOT_PATH.'includes/core.php');
  8. switch ($_GET['d']) {
  9. //Uploading with HTML response and errors
  10. case 'upload':
  11. //If no file is being posted, show the error page and exit.
  12. if(empty($_FILES['file']['name'])){
  13. include_once(CONFIG_ROOT_PATH.'error.php');
  14. exit(0);
  15. }
  16. //Set the name value to the original filename
  17. $name = $_FILES['file']['name'];
  18. $arg = 'custom_original';
  19. //If the value name contains a custom name, set the name value
  20. if(!empty($_POST['name'])){
  21. $name = $_POST['name'];}
  22. //If value contains anything, keep original filename
  23. if(!empty($_POST['randomname'])){
  24. $name = $_FILES['file']['name'];
  25. $arg = 'random';}
  26. //Call the save function which sends the file+name
  27. save_file($_FILES['file']['tmp_name'], $name, $arg, 'normal');
  28. break;
  29. //Uploading without HTML response or errors
  30. case 'upload-tool':
  31. //If no file is being posted, show the error page and exit.
  32. if(empty($_FILES['file']['name'])){
  33. exit('You did not send a file, try again.');
  34. }
  35. //Set the name value to the original filename
  36. $name = $_FILES['file']['name'];
  37. $arg = 'custom_original';
  38. //If the value name contains a custom name, set the name value
  39. if(!empty($_POST['name'])){
  40. $name = $_POST['name'];}
  41. //If value contains anything, keep original filename
  42. if(!empty($_POST['randomname'])){
  43. $name = $_FILES['file']['name'];
  44. $arg = 'random';}
  45. //Call the save function which sends the file+name
  46. save_file($_FILES['file']['tmp_name'], $name, $arg, 'tool');
  47. break;
  48. case 'extend-time':
  49. break;
  50. default:
  51. //If no correct valid argument for the api to perform on, tell them to enter a valid one
  52. exit('Please provide a valid argument. Example: curl -i -F name=test.jpg -F file=@localfile.jpg '.CONFIG_ROOT_URL.'/api.php?d=upload-tool');
  53. break;
  54. }
  55. }else{
  56. //*1
  57. header('Location: index.html');
  58. }