how to access a file from target URL after an XMLHttpRequest post
<p>I am trying to upload and save an image file to a server using an <code>XMLHttpRequest</code> POST after allowing file selection to be done on the client's side using HTML5 and java script (using an html input element). </p>

<p>My problem is that cannot find out how to actually get a hold of the file from the server side and save it to the server.</p>

<p>This is my code:</p>

<pre><code>                    xhr = new XMLHttpRequest();

                    // Update progress bar etc
                    xhr.upload.addEventListener("progress", function(evt) {
        if (evt.lengthComputable) {
        progressBar.style.width = (evt.loaded / evt.total) * 100 + "%";
        }
        else {
        // No data to calculate on
        }
        }, false);

        // File uploaded
        xhr.addEventListener("load", function() {
        progressBarContainer.className += " uploaded";
        progressBar.innerHTML = "Uploaded!";
        }, false);

        xhr.open("post", "imageSave.aspx", true);

        // Set appropriate headers
                   xhr.setRequestHeader("Content-Type", "multipart/form-data");
           xhr.setRequestHeader("X-File-Name", file.fileName);
           xhr.setRequestHeader("X-File-Size", file.fileSize);
           xhr.setRequestHeader("X-File-Type", file.type);

           // Send the file
           xhr.send(file);
</code></pre>
