I need to transfer a file (.zip) from a clients third-party-website to mine.
GM-Snippet (commented out other trys)
GM_xmlhttpRequest({
method: "GET",
url: dlurl,
timeout:0,
onload: function(resp) {
var conti=resp.responseText;
alert("goup");
GM_xmlhttpRequest({
method: "POST",
url: "http://absolut-fair.com/wbb_back/api.php?id=3",
overrideMimeType: 'text/plain; charset=x-user-defined',
data:"chk=1&data="+base64_encode(conti),
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
onload: function(resp) {
var conti=resp.responseText;
if(conti=="1") alert("upload erfolgreich");
else alert(conti);
//....
PHP-Snippet
$name="test.txt";
uploadfile(base64_decode($_POST["data"]),detect_mime($name),$name);
Problem
All of the decoded files are corrupted when I try to open them. The problem is sending binary data. Sending raw text worked fine!
//Update
I just downloaded the healthy and the invalid zip files and it appears that the invalid one handles a lot of space filling useless code segments. So i got the feeling that base64 is not able to fully encode/decode binary data. Anyone has any knowledge?
I attached a screenshots of the source to make it clear!
The valid file:
The invalid one: