I'm trying to make an image uploader with php and jquery but i can't get it to work.
My question is
Why is $_FILES['image']; empty?
Heres my code
Html
index.php
<form id="uploadForm" action="" method="post">
<input name="image" type="file" id="image" />
<a href="#" id="uploadforms">Upload</a>
</form>
<div id="uploadresult"></div>
jQuery
javascript.js
function uploadimages(){
$.ajax({
type: 'POST',
url: '../ajax/upload.php',
processData: false,
contentType: false,
cache: false,
data: new FormData(this),
success: function (data) {
$("#uploadresult").html(data);
},
});
}
$("#uploadforms").click(function(){
uploadimages();
});
Php
Upload.php
<?php
if(!empty($_FILES['image'])) {
echo "Upload image";
}
else{
echo "Error";
}
?>