I am facing an issue with the code snippet below. The script is designed to send 2 variables and a file to a PHP script for uploading to a server. While everything works fine in Firefox and Chrome, Opera throws an error "ReferenceError: Undefined variable: FormData".
I am unable to test in IE or Safari due to my dependency on the File API. Although there are other functions within the script, only these 2 are crucial as they are where the error originates.
datumActiviteit = "testxx";
naamActiviteit = "testyy";
function sendFiles() {
try{
var imgs = document.querySelectorAll(".obj");
for (var i = 0; i < imgs.length; i++) {
new BestandenUploaden(imgs[i],imgs[i].file);
}
}
catch(ex){alert(ex);}
}
function BestandenUploaden(img,file){
try{
var formData = new FormData();
formData.append("activiteit", naamActiviteit);
formData.append("datum", datumActiviteit);
formData.append("bestand", file);
var oXHR = new XMLHttpRequest();
oXHR.open("POST", "launcherV2.php");
oXHR.onreadystatechange = function (oEvent) {
if (oXHR.readyState==4 && oXHR.status==200) {
if (oXHR.responseText == "continue") {
img.parentNode.lastChild.style.opacity = "1.0";
img.parentNode.lastChild.style.backgroundColor = "transparent";
img.parentNode.lastChild.style.backgroundImage = "url(../afbeeldingen/rocket/complete.png)";
}
else {
window.alert(oXHR.responseText);
}
}
else{
window.alert("readyState or status error :", oXHR.statusText);
}
};
oXHR.send(formData);
}
catch(err){alert(err)};
};
Any insights into why only Opera(v11.62) would be throwing this particular error?