PHP Classes

File: uploader.js

Recommend this page to a friend!
  Classes of Er. Rochak Chauhan   AJAX File Uploader   uploader.js   Download  
File: uploader.js
Role: Auxiliary data
Content type: text/plain
Description: javascript file
Class: AJAX File Uploader
Browse files uploaded without page reloading
Author: By
Last change: Fixed a bug to display properly on IE.
Date: 15 years ago
Size: 1,390 bytes


Class file image Download
var http=createRequestObject(); var uploader=""; var uploadDir=""; var dirname=""; var filename=""; var timeInterval=""; var idname=""; var uploaderId=""; function createRequestObject() { var obj; var browser = navigator.appName; if(browser == "Microsoft Internet Explorer"){ return new ActiveXObject("Microsoft.XMLHTTP"); } else{ return new XMLHttpRequest(); } } function traceUpload() { http.onreadystatechange = handleResponse;"GET", 'imageupload.php?uploadDir='+uploadDir+'&dirname='+dirname+'&filename='+filename+'&uploader='+uploader); http.send(null); } function handleResponse() { if(http.readyState == 4){ var response=http.responseText; if(response.indexOf("File uploaded") != -1){ clearInterval(timeInterval); //document.getElementById('loading'+idname).innerHTML=""; } document.getElementById(uploaderId).innerHTML=response; } else { document.getElementById(uploaderId).innerHTML="Uploading File. Please wait..."; } } function uploadFile(obj, dname) { uploadDir=obj.value;; dirname=dname; filename=uploadDir.substr(uploadDir.lastIndexOf('\\')+1); uploaderId = 'uploader'; uploader =; document.getElementById('formName'; timeInterval=setInterval("traceUpload()", 1500); }