I have been trying hard to know what can be the issue of Uploading image. Tried several ways, but couldn't succeed in Ajax. If I will upload file without using Ajax, it works fine : I am new to AJAX , so thus may be missing some trick.
Moreover, The full form is working perfectly with ajax, but $_FILES is creating a problem . ERROR IS:
Notice: Undefined index: Upload in Z:\xampp\htdocs\webseite\a.php on line 70
What can be the reason ?
I know there are several posts related to that, but none matches with XMLHttpRequest .
Thanks
This is the code.
HTML file has HTML code and Javascript/AJAX code. Second file : a.php has PHP code.
<div class="form-group mygroup">
<label for="name"> Upload (optional) </label>
<input type="file" class="form-control" name="Upload" id="Upload">
</div>
<script>
var xhttp = new XMLHttpRequest();
var Upload_rek=document.getElementById('Upload').value;
xhttp.open('GET', 'a.php?&Upload_var='+Upload_rek+'&Senden_var='+Senden_rek, true);
xhttp.send();
</script>
<?php
$target = "uploads/".basename($_FILES['Upload']['name']);
?>