I have seen tons of ways to do the same thing and some scripts just don't intertwine with each other from jQuery to plain JavaScript and ajax, quite the confusion.
Anyway I found this upload script that only uploads single files and I challenge myself to turn it into a multi file uploader and I am getting this little issue every time I try changing up few variables that I read about to parse my php script with this top lines below.
function uploadFile(){
var file = _("file").files[0]; //This line is the issue, changed it around still gave null errors
var formdata = new FormData();
formdata.append("file1", file);
var ajax = new XMLHttpRequest();
and my HTML looks like this
<form id="upload_form" enctype="multipart/form-data" method="post">
<input type="file" name="file1" id="file1"><br>
<input type="button" value="Upload File" onclick="uploadFile()">
</form>
I tried every variable to not give errors and yet I get object or variable and null errors.
Edit
This is what I been working with and this is the part that Is giving issues, I have more functions but they are in different link with the output of the parsing php file to handle progress bar and error handling. this part below is what I have been switching up since yesterday afternoon without success. @EmielZuurbier I tried incoperating your addon and still error messages about uploadFile not being a variable etc.
}
function uploadFile(){
var file = _("file1").files[0];
var formdata = new FormData();
formdata.append("file1", file);
var ajax = new XMLHttpRequest();
ajax.upload.addEventListener("progress", progressHandler, false);
ajax.addEventListener("load", completeHandler, false);
ajax.addEventListener("error", errorHandler, false);
ajax.addEventListener("abort", abortHandler, false);
ajax.open("POST", “plistingscript.php");
ajax.send(formdata);
}