'Where do PHP echos go when you are posting to a page?

This might be a dumb question. I'm fairly new to PHP. I am trying to get a look at some echo statements from a page I'm posting to but never actually going to. I can't go directly to the page's url because without the post info it will break. Is there any way to view what PHP echos in the developer console or anywhere else?

Here is the Ajax:

function uploadImage(image) {
  
      var data = new FormData();
      data.append("image", image);

      imgurl = 'url';
      filepath = 'path';
      $.ajax({
        url: imgurl,
        cache: false,
        contentType: false,
        processData: false,
        data: data,
        type: "post",
        success: function(url) {
          var image = $('<img class="comment_image">').attr('src', path + url);
          $('#summernote').summernote("insertNode", image[0]);
        },
        error: function(data) {
          console.log(data);
        }
      });
    }

And here is the php file:

<?php
  $image = $_FILES['image']['name'];
  $uploaddir = 'path';
  $uploadfile = $uploaddir . basename($image);
  if( move_uploaded_file($_FILES['image']['tmp_name'],$uploadfile)) {
    echo $uploadfile;
  } else {
    echo "Unable to Upload";
  }
?>

So this code runs fine but I'm not sure where the echos end up and how to view them, there is more info I want to print. Please help!



Solution 1:[1]

Here is a basic example...

HTML (Form)

<form action="script.php" method="POST">
    <input name="foo">
    <input type="submit" value="Submit">
</form>

PHP Script (script.php)

<?php

    if($_POST){
        echo '<pre>';
        print_r($_POST); // See what was 'POST'ed to your script.
        echo '</pre>';
        exit;
    }

    // The rest of your PHP script...

Another option (rather than using a HTML form) would be to use a tool like POSTMAN which can be useful for simulating all types of requests to pages (and APIs)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Simon K