PHP AJAX file upload

22,512

Here is a simple ajax file uploader

Uploadify

And if you don't want flash, you may use this one;

AxUploader

Share:
22,512
Admin
Author by

Admin

Updated on September 30, 2020

Comments

  • Admin
    Admin over 3 years

    i've looked all over stackoverflow and the general internet and i can't find a simple AJAX file uploader (Just form submission). The ones i have found aren't flexible enough and don't fit my purpose. If i could ajust this script to file uploads, that would be great:

    <script type="text/javascript">
     function upload(str)
     {
     if (str.length==0)
     { 
    document.getElementById("txtHint").innerHTML="";
     return;
      }
     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("hint").innerHTML=xmlhttp.responseText;
         }
       }
     xmlhttp.open("GET","ajax/link.php?q="+str,true);
     xmlhttp.send();
     }
    

    In the HTML i would have

    <input type='file' onblur='upload(this.value)'>
    

    Thanks

  • Admin
    Admin about 12 years
    Hi, the problem with that is that i need to have single upload button, and once someone has clicked uploaded the file it automattically uploads. Only one file will be uploaded at a time.
  • Admin
    Admin about 12 years
    Thanks, I just used AxUploader. Thats exactly what i was looking for