Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make documents upload using AJAX with progress Bar
    primarykey
    data
    text
    <p>I want to make an upload page for my site so that documents get uploaded asynchronously, I tried using AJAX, but AJAX has a limited access to the users filesystem, and when the information is sent to the server only the file name appears without the directory, I would like suggestion on how to do this easily without using JQuery, and also I would like to know if there is a way to monitor the progress of a file upload, so that I could add a progress bar to my site.</p> <pre><code>function createXMLHttpRequestObject(){ var xmlHttp = 3; if(window.ActiveXObject){ try{ //test for new version of internet Explorer xmlHttp = new ActiveXObject("Msxml.XMLHTTP"); } catch(e){ try{ xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ xmlHttp = 2; } } } else{ try{ xmlHttp = new XMLHttpRequest(); } catch(e){ xmlHttp = 1; } } if(!xmlHttp){ alert("Error creating Objece"); } else{ var xHttpArr = new Array(); xHttpArr.push(xmlHttp); var i = xHttpArr.length - 1; return xHttpArr[i]; } } function process(xmlHttp, i){ if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0){ //value = encodeURIComponent( objRef.value ); xmlHttp.open("GET", "php/AjaxBody.php?value="+i, true); xmlHttp.onreadystatechange = handleServerResponse; xmlHttp.send(null); } else{ alert("Hold on"); } } function handleServerResponse(){ if(test.readyState == 1 || test.readyState == 2 || test.readyState == 3){ } if (test.readyState == 4){ if(test.status == 200){ txtResponse = test.responseText; bodyDiv = document.getElementById("body"); bodyDiv.innerHTML = txtResponse; } else{ alert("Error with the xmlHttp status"); } } /* else{ alert("Error with the xmlHttp readystate: " + x.status); } */ } </code></pre> <p>Above is the code that creates the Object</p> <pre><code> button.onclick = function() { send = createXMLHttpRequestObject(); frmUpload = document.getElementById("frmUpload"); file = document.getElementById("fileUpload"); processSending(send, frmUpload); } </code></pre> <p>Above when the process method is called to send the file, on the server I try to echo the file path, only the the name appears, like this</p> <pre><code>&lt;?php echo $_GET['value']; ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload