0

I have a XMLHttpRequest to send a courseName to php file on the server like this:

    const xhr = new XMLHttpRequest();
    xhr.onload = function(e) {
        if(this.readyState === 4) {
            console.log("Server returned: ",e.target.responseText);
        }
    };
    const fd = new FormData();
    
    fd.append("courseName", 'Math');
    xhr.open("POST", "upload.php", true);
    xhr.send(fd);

PHP:

<?php

echo $_FILES['courseName']

?>

But nothing is returned, I'm confused please help... it should return Math, Doesn't it?

Sara Ree
  • 3,417
  • 12
  • 48

1 Answers1

1

The network doesn't show any data sent over.

How to use FormData for AJAX file upload?

Shows you how to send files using FormData ...

Best, Smith