0

Hello, i have create e form with ajax for upload file with XMLHttpRequest

page.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, $_FILES);
echo"OK";

?>

Don't work and don't upload, why?
:-(

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by stbuchok
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.