//获取上传文件
let url="index.php?r=moduleName/ControllerName/ActionName"
let myForm = document.getElementById('formId');
let formData = new FormData(myForm);
//获取要上传的文件列表
let file = $("[name=upload-name]");
//添加到formData中
for(let w = 0;w<file.length;w++){
formData.append("files[]" , file[w]);
}
$.ajax({
type : "POST",
url : url,
data : formData,
async: false,
cache: false,
contentType: false,
processData: false,
success : function(res) {
//转换为
let jsonObj=eval('('+res+')');
if(jsonObj.code === "1"){
//跳转
window.location.href = jsonObj.url;
}else{
alert('信息提交失败!')
}
}
});