PHP AJAX file upload
22,512
Here is a simple ajax file uploader
And if you don't want flash, you may use this one;
Author by
Admin
Updated on September 30, 2020Comments
-
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 about 12 yearsHi, 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 about 12 yearsThanks, I just used AxUploader. Thats exactly what i was looking for