Salve a tutti, secondo voi non è proprio possibile fare UPLOAD con XMLHttpRequest?
perchè ho fatto una prova:
pagina1.php
<script>
function upload()
{
var file_upload = document.form1.file_upload.files;
/*
if(xmlhttp5.readyState == 1)
{
alert("Attendere!");
} else
*/
// code for IE7+, Firefox, Chrome, Opera, Safari
if(window.XMLHttpRequest)
{
xmlhttp5 = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp5 = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp5.onreadystatechange = function()
{
if(xmlhttp5.readyState == 4 && xmlhttp5.status == 200)
{
alert(xmlhttp5.responseText);
}
}
xmlhttp5.open("PUT", "upload.php?file_upload="+ file_upload, true);
xmlhttp5.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttp5.send();
}
</script>
<form name="form1" id="form1" method="post" enctype="multipart/form-data">
<input type="file" name="file_upload" id="file_upload" /><input type="button" value="Upload" onclick="upload();">
</form>
upload.php
<?php
copy($_FILES['file_upload']['tmp_name'], $_FILES['file_upload']['name']);
echo"OK";
?>
Non funziona e non carica..