<!-- /**
* @Author: cyany_blue
* @Date: 2018-12-12 21:24:54
* @Last Modified by: cyany_blue
* @Last Modified time: 2018-12-12 22:09:15
*/ -->
<!DOCTYPE html>
<html lang="en">
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<body>
<form onsubmit="return false" enctype="multipart/form-data" method="post" name="fileinfo" id="form1"> //阻止默认刷新retrue false;
<input type="file" name="file[]" multiple="true"> 单文件上传file,多文件上传file[]接收
<input type="submit" value="submit" class="sumbit1">
</form>
</body>
<script>
$(function(){
$(".sumbit1").click(function(ev){
var formData = new FormData(document.querySelector("#form1"));
console.log(formData)
$.ajax({
url:'upload.php',
type:'post',
data:formData,
contentType: false, //很重要
processData:false,//很重要,不然会报非法错误。。。
success:function(res){
console.log(res);
}
});
// ev.preventDefault();
});
})
</script>
</html>
<?php
/**
* @Author: cyany_blue
* @Date: 2018-12-12 21:20:53
* @Last Modified by: cyany_blue
* @Last Modified time: 2018-12-12 21:43:43
*/
$uploads = $_FILES["file"];
var_dump($uploads);
?>