it is not possible to process a file upload through the XMLHttpRequest object, becouse JavaScript has no access to your computer's file system. But, there are still ways to perform Ajax-like functionality for this task without making use of the XMLHttpRequest object.
This can be done via a hidden <iframe>
create a form and hidden iframe.
The JavaScript function uses the submit() event to sends form data to the iframe.
The PHP script uploads the image file on the server
This second
JS function is used to display the image uploaded. It takes the address of the file loaded on the server and adds in a DIV (with "innerHTML") an <img> tag with the image uploaded.
hope it works..!