这适用于Chrome和Firefox,但不适用于IE,问题是:
var formData = new FormData($('form')[0]); // included in script
看我的代码:
HTML:
<form enctype="multipart/form-data">
<input id="img_file" name="file" type="file" accept="image/x-png, image/gif, image/jpeg">
<a href="#" id="upload" class="selective">Upload</a>
</form>
JS:
$(document).on('click', '#upload', function(event) {
event.preventDefault();
var formData = new FormData($('form')[0]);
$.ajax({
type: 'POST',
url: 'process.php',
data: formData,
cache: false,
contentType: false,
processData: false,
success: function(formData){
alert(formData);
}
});
});
有什么建议吗?