html
<form method="post" action="" id="dataForm">
<input type="file" name="embleLoader"/>
<button name="sub-comfirm" class="btn-selection-content" type="submit" id="sub-comfirm">Send</button>
</form>
Js
$(document).ready(function(){
$('#dataForm').on('submit', function(e) {
e.preventDefault();
SendData();
});
});
function SendData(){
var postData = $("#dataForm").serializeArray();
$.ajax({
type: "POST",
url: "checkinput.php",
data: postData,
success:function(data)
{
console.log(data);
console.log("suceess");
},
error: function(jqXHR, textStatus, errorThrown)
{
console.log("failure");
}
});
}
php
<?php
$get = $_FILES["embleLoader"];
print_r($_FILES);
?>
my intention is to pass my input file (image value) to php using ajax , the data to pass to php and i use $_FILES to check my input file data , it give me empty array , why i cant get the data using my code ? should it be some inside the array tmp_name or error>0 . something like that?
how do i pass image using input file and pass to php.
return result:
Array
(
)
inputfile.html:30 suceess