For some strange reason the following code doesn't print out anything when I upload a file. I thought the HTML5 / jQuery would return something, but I'm not getting anything back when I print out my variables.
<? print_r($_FILES) ?>
<? print_r($_POST) ?>
<? print_r($_GET) ?>
<? print_r($_REQUEST) ?>
<form enctype="multipart/form-data" action="/upload.php"
method="post" class="putImages">
<input name="media[]" type="file" multiple/>
<input class="button" type="submit" alt="Upload" value="Upload" />
</form>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(function() {
var data = new FormData($('input[name^="media"]'));
jQuery.each($('input[name^="media"]')[0].files, function(i, file) {
data.append(i, file);
});
$(':file').on('change', function() {
$.ajax({
type: 'POST',
data: data,
url: 'http://localhost/upload.php',
cache: false,
contentType: false,
processData: false,
success: function(data){
alert(data);
}
});
});
});
</script>