Currently I have the following code:
<div id="insertreading">Insert Reading</div>
<form id="confirmreadingform" enctype="multipart/form-data" method="post" style="display: none;">
<input id="uploadreading" name="fileToUpload2" type="file" value="Upload Resources"/>
</form>
</div>
<div id="submitchanges">Submit Changes</div>
Basically I want it so that when submitchanges is clicked, it will take the file the user has entered in the form and a php script will process/get the file(using $_FILES). I know I could just use an action="upload.php" in the form but is it possible without it. Would I need to use Ajax?
Is the following correct:
var formData = new FormData($("#confirmreadingform"));
formData.append('reading', $('#uploadreading'));
$.ajax({
type: 'POST',
url: 'upload.php',
data: formData,
success: function (data) {
alert(data)
},
});