Buenas,
No se si es el problema es de Jquery o de PHP. Tengo este fichero de prueba y soy incapaz de recuperar el fichero enviado a través de Ajax. Si lo mando normal no hay problema. A través de Ajax los arrays $_POST y $_FILES están siempre vacíos.
Código PHP:
Ver original<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<?php
echo '<pre>';
echo '</pre>';
?>
<div id="add-file">
<form id="form-file" action="index.php" method="post">
<input id="fileupload" type="file" name="fichero"/>
<input type="hidden" name="subcarpeta" value=""/>
<input type="hidden" name="id_usuario" value=""/>
<input type="submit"></input>
</form>
</div>
<script>
$('#form-file').submit(function(event){
event.preventDefault();
$.ajax({
error: function(jqXHR, textStatus, errorThrown){},
data: {
datos: new FormData($(this)[0])
},
success: function(data, textStatus, jqXHR)
{
console.log(data);
},
url: "index.php",
method: "POST",
processData: false,
contentType: false,
cache: false,
dataType: "html"
}
);
});
</script>
</body>
</html>