Reply to Trying to make class.upload.php with Ajax but i need help

Trying to make class.upload.php with Ajax but i need help new!
by Alex, 11 years, 7 months ago
I have this form :
<form id="the-form" action="upload.php" enctype="multipart/form-data">
  <input id="the-file" type="file" size="32" name="file[]" value="">
  <input id="the-file" type="file" size="32" name="file[]" value="">
  <input id="the-file" type="file" size="32" name="file[]" value="">
</form>

And i have this Ajax script:
var fileInput = document.getElementById('the-form');
  form.onsubmit = function() {
  var file = fileInput.files[0];
  var formData = new FormData();
  formData.append('file', file);
					  	
  var xhr = new XMLHttpRequest();
  // Add any event handlers here...
  xhr.open('POST', form.getAttribute('action'), true);
  xhr.send(formData);
  return false; // To avoid actual submission of the form
}

I'm trying to make an image/s upload without refreshing the page with the class.upload.php but i can't solve it. Every time i do this i'm getting some errors and the main error is :
Notice: Undefined index: file in C:\wamp\www\OP\admin\test\upload.php on line 6
Warning: Invalid argument supplied for foreach() in C:\wamp\www\OP\admin\test\upload.php on line 6


Any help with this issue? any suggestions or past experiences that could solve this is welcome. Thanks.Reply

Your reply

Name *
Email 
Title *
Text *
CAPTCHA image
Enter the code displayed on the image:
Click on the image to generate another one if it is hard to read it. The case is important