HTML:
<form id="imageform" method="post" enctype="multipart/form-data" >
Upload image <input type="file" name="photoimg" id="photoimg" />
</form>
<div id='preview'></div>
JavaScript的:
$('#photoimg').change(function() {
$("#preview").html('');
$("#preview").html('<img src="loader.gif" alt="Uploading...."/>');
var data = new FormData();
jQuery.each($('#photoimg')[0].files, function(i, file) {
data.append('file-' + i, file);
});
$.ajax({
url: 'ajaximage.php',
data: data,
contentType: false,
processData: false,
type: 'POST',
success: function(data) {}
});
});
PHP:
print_r($_FILES);
需要帮助来解决此问题。