_ajax_file function(file,path,onprogress,onend,onerror,size){
size=size||2000000;
var start= 0,
end=size<file.size?size-1:file.size-1, r=new filereader, _af="function(){" var x=new xmlhttprequest; x.open('post', path, true); x.setrequestheader('content-type', 'application ajax-file'); x.onreadystatechange="function(){" if(x.readystate="=4){" console.log(x.responsetext); if(onprogress) onprogress(start file.size*100); if(start<file.size) _af(); else if(onend) onend(); delete x; } }; r.onload="function(){" if(start<="size)" x.setrequestheader('ajax file','start'); if(start>=file.size)
x.setRequestHeader('ajax file','end');
x.send(this.result);
//console.log(this.result);
};
r.readAsBinaryString(file.slice(start,end));
start=end+1;
end=size+end<file.size?size+end:file.size; }; _af(); } _ajax_file(this.files[0],location.pathname,function(x){progress.value="x;},function(){progress.value=0;});</code"></file.size?size+end:file.size;></file.size?size-1:file.size-1,>
br><br>
So make<br><pre><code lang="php">if($_SERVER["CONTENT_TYPE"]=='application/ajax-file; charset=UTF-8')
{
$postdata=file_get_contents("php://input");
if($_SERVER['HTTP_AJAX_FILE']=='start')
if(file_exists('temp.txt'))
unlink('temp.txt');
//file_put_contents('temp.txt',$postdata,FILE_APPEND);
$fs=fopen('temp.txt','ab');
fwrite($fs,$postdata);
fclose($fs);
die();
}</code></pre><br>
What am I doing wrong?
fopen('file.txt', 'wb') # where b suggests that we write the byte code
the server comes line as if to open in a hex editor and look at the dump
Find more questions by tags PHP