0

Please help me in creating a multiple file upload and then process it in ajax so that it can view into the page before the form is submitted

this is my form

<form name="create_memo" method="post" ENCTYPE="multipart/form-data">
<input id = "memofile" type="file" name="img[]" onchange="uploader();" multiple />
<input type="submit">
</form>

<div id="memoupload">
</div>

this is the javascript

function upload()
{
var xmlhttp;
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }


xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("memoupload").innerHTML=xmlhttp.responseText;
    }
  }

  var file = document.getElementById('memofile').value;

xmlhttp.open("GET","uploadmemo.php?file="+file,true);
xmlhttp.send();
}

php file

i have to count the file in img[] file and upload it into database.
<?php
$file=$_GET['img']['name'];
echo count('$file');
?>

please help me.. i dont know how to initiate this..

Thanks in advance..

Edited by Nick Evan: Fixed formatting

3
Contributors
2
Replies
10
Views
5 Years
Discussion Span
Last Post by diafol
0

take a look at the jquery ajax. far fewer lines of code. it would then allow you to make multiple instances of a file upload option like "upload another file".

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.