I'm using ajax to post form data and upload files from client to server (php),
my problem comes when I have to get the file content in the server side
for Some reason, $_FILES variable seems to come empty no matter what I try. Here's the code I have so far...
<!-- html5 -->
<form id="uploadImg" enctype="multipart/form-data">
<label>Panorámica</label>
<div class="custom-file">
<input type="file" class="custom-file-input" id="panoramica" name="panoramica" >
<label class="custom-file-label" for="panoramica">Seleccionar Archivo</label>
</form>
//jquery
$('#uploadImg').on('submit', function(e){
e.preventDefault();
var url = "upfilephp.php";
jQuery.ajax({
url: url,
type: "POST",
data: new FormData(this),
contentype: false,
cache: false,
processData: false,
success: function (data) {
console.log(data)
},
error: function(err){
console.log(err)
}
});
//php
<?php
if(!empty($_FILES['panoramica']['name'])){
echo 'no problem';
}else{
echo 'img is empty';
}
?>
Any idea how to solve this or what I'm I doing wrong?