I tried to research pretty much everything already, but I didnt find the final solution to fix my code. As you can see in the debug image, the file prop can be read. In PHP, I the result of print_r($_FILES); exit; is an empty array. The problem seems to be event.preventDefault();. The submit has to be prevent but the file still has to be generated.
$("#cardgeneratorForm").on("submit", function (event) {
event.preventDefault();
var artworkimageinput = $('#inputPicture').prop('files')[0];
var artworkimage = new FormData();
artworkimage.append('file', artworkimageinput);
$.ajax({
url: 'generatecard.php',
method: 'POST',
data: {
artworkimage: artworkimage,
},
cache: false,
processData: false,
contentType: false,
success : function(filename){
},
fail: function(){
}
});
PHP
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
move_uploaded_file($_FILES['file']['tmp_name'], 'artwork/' . $_FILES['file']['name']);
}
HTML
<form class="cardgeneratorForm" id="cardgeneratorForm" method="post" enctype="multipart/form-data" action="generatecard.php">
<div class="inputPicture-container custom-file col-12">
<input type="file" name="file" class="custom-file-input" accept='.jpg, .jpeg, .png, .webp' id="inputPicture" lang="en">
<label class="custom-file-label" for="inputPicture">Card Picture</label>
</div>
<button class="btn btn-primary btn-block btn-xs reset-button">
<span><i class="fas fa-redo"></i>Reset</span>
</button>
</form>

