upload.php 836 B

1234567891011121314151617181920212223
  1. <?php
  2. header('Access-Control-Allow-Origin: *');
  3. $target_dir = "uploads/";
  4. $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
  5. $uploadOk = 1;
  6. $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
  7. // Check if $uploadOk is set to 0 by an error
  8. if ($uploadOk == 0) {
  9. echo "Sorry, your file was not uploaded.";
  10. // if everything is ok, try to upload file
  11. } else {
  12. if ($_POST['token'] == "SECRET" && move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
  13. echo "The file ". htmlspecialchars( basename( $_FILES["fileToUpload"]["name"])). " has been uploaded.";
  14. $old_path = getcwd();
  15. $output = shell_exec('./test.sh');
  16. } else {
  17. echo "Sorry, there was an error uploading your file.";
  18. }
  19. }
  20. ?>