Ciao a tutti mi sto cimentando ora con un pò di ajax, ora ho un problema:

fare un semplice upload con ajax, vi spiego come lo ho impostato,

ho la index.php così fatta:
Codice PHP:
<html>

<
head>
<
title>AjaxUpload</title>

<
style type="text/css"


#form{
 
positionrelative;
 
floatleft;
 
width400px;
 
height200px;
 
background-colorblue;
 
coloryellow;
 
margin-top10px;
 
margin-left10px;
 
padding-top10px;
 
padding-left10px;
}


#resto{
 
positionrelative;
 
floatleft;
 
width400px;
 
height200px;
 
background-coloryellow;
 
colorblack;
 
margin-top10px;
 
margin-left10px;
 
padding-top10px;
 
padding-left10px;


}
</
style>
<
script type="text/javascript">

var 
myRequest null;

function 
CreateXmlHttpReq(handler) {
  var 
xmlhttp null;
  try {
    
xmlhttp = new XMLHttpRequest();
  } catch(
e) {
    try {
        
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(
e) {
        
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  
xmlhttp.onreadystatechange handler;
  return 
xmlhttp;
}

function 
myHandler() {
    if (
myRequest.readyState == && myRequest.status == 200) {
       var 
document.getElementById("resto");
       
document.getElementById('sub').value "Carica";
        
e.innerHTML =myRequest.responseText;
    }
     if (
myRequest.readyState == 1) {
           var 
document.getElementById("resto");
           
document.getElementById('sub').value "Attendi in caricamento";
            
e.innerHTML ="attendi";
    }
}

function 
upload() {
    
document.getElementById('sub').disabled true;
    
    
myRequest CreateXmlHttpReq(myHandler);
    
myRequest.open("POST","upload.php?rand="+escape(Math.random()));
    
myRequest.send(null);
    
}


</script>

</head>

<body>
<div id="form">
<form method="POST" action="" enctype="multipart/form-data">

<input type="file" name="image"/>

<input id="sub" name="sub" type="button" onclick="upload();" value="Carica">


</form>
</div>
<div id="resto">

</div>

</body>
</html> 
ora vorrei sapere come far passare alla pagina upload il file come fosse un normale input di tipo file.

Grazie a chi mi spiega il meccanismo e Buon Anno Nuovo