var reader = new FileReader();
reader.readAsBinaryString(file);
I send the file object like this...
Code: Select all
var http = new XMLHttpRequest();
var url = "upload.php";
http.open("POST", url, true);
//Send the proper header information along with the request
//http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
//http.setRequestHeader("Content-length", 0);
//http.setRequestHeader("Connection", "close");
http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
div.innerHTML = http.responseText;
}
}
http.send(file);
file.length
it returns with the value 69,874 bytes which is the exact file size.
after the post on the php end of thing I use this simple code to read the file
Code: Select all
<?php
$postdata = file_get_contents("php://input");
echo "File size on the server is: ".strlen(stripslashes($postdata))." bytes. <br />";
echo $postdata;
$fp = fopen("fighter.txt", "wb");
fwrite($fp, $postdata);
fclose($fp);
?>
where is the extra data coming from do you guys have any idea?