[英]Multiple File Upload Using Ajax Jquery
我已经编写了ajax多个文件上传表单,但是无法正常工作。
HTML代码:
<form method="post" id="postfrom" enctype="multipart/form-data">
<input type="file" name="file" id="file" class="inputfile" multiple
accept=".mp4, .mov, .m4v, .MPEG-4, .gif, .jpg, .png"/>
</form>
<button type="button" class="btnb btnb-primary" id="submitpost"><i class="fa fa-paper-plane-o" aria-hidden="true"></i> Submit</button>
jQuery代码:
$(document).on("click", "#submitpost", function(){
$("#postfrom").submit();
});
$("#postfrom").on('submit', function(e){
e.preventDefault();
$.ajax({
url : "/php/post_submit.php",
type: "POST",
cache: false,
contentType: false,
processData: false,
data : new FormData(this),
success: function(response){
$('.result').html(response);
alert(response);
},
error: function (request, status, error) {
alert(request.responseText);
}
});
});
PHP代码:
<?php
print_r($_FILES);
?>
如何解决这个错误。 我没有从PHP响应中得到任何东西。 我只得到Array()
响应。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.