js部分:
$('#btn-up').click(function (){
$('#checkfile-upload').click();
});
$('#checkfile-upload').on('change',function(){
var checkPlanId=$("#checkPlanId").val();
var picker=pickers;
var data={"tableId":checkPlanId,"remarks":picker};
var oFiles = document.getElementById("checkfile-upload").files;
var params = new FormData();
params.append('file',oFiles[0]);
$.ajax({
type:'post',
url:path + "/checkdailyplan/checkDailyPlan/upload?tableId="+checkPlanId+"&remarks="+picker,
data:params,
cache: false,
contentType: false,
processData: false,
success:function(id){
if(id==null||id==""){
alert("上传失败")
}else {
var info=id.split(";");
$("#attachID").val(info[0]);
$('#filename').html(info[1]);
}
}
});
});
h5部分:
<input id="btn-up" class="btn btn-primary"
type="button" value="上传计划文件"
style="float: right;margin-right: 50px;margin-bottom: 10px">
<input type="file" id="checkfile-upload" style="display: none"/>
参考网址:https://blog.csdn.net/dear_mr/article/details/56040549