I'm trying to upload a screenshot with a file input and an ajax request. This is my request code:
var formData= new FormData();
formData.append('pictureFile', fileInput.files[0]);
$.ajax({
url: 'data/Upload.php',
type: 'POST',
processData: false,
contentType: false,
data: formData,
success: function (result) {
console.log(result);
}
});
My php code:
$fileName = $_FILES['pictureFile']['tmp_name'];
echo $fileName;
move_uploaded_file($fileName,"dirname");
The upload doesn't seem to be working however, the echo shows me this:
/data/sites/web/hostname/tmp/phplywZbl
When I check this directory right after making the request, it's empty!
I checked the php.ini file and file uploads are definitely on (max size = 2M, screenshot is 25kb).
Does anyone know what's wrong?