This commit is contained in:
shilixia 2019-10-08 09:53:16 +08:00
parent a6c7571ccc
commit 08e42ae7ad
1 changed files with 25 additions and 27 deletions

View File

@ -128,7 +128,7 @@
<a class="list" href="javascript:;">
<input id="file" type="file" name="myfile" onchange="UpladFile();" /><span>选择文件</span>
</a>
<button class="btn" type="button" onclick="sub();">上传</button>
</p>
<!--显示消失-->
@ -215,13 +215,6 @@
$(".el-upload-list").css("display", "block");
$(".el-upload-list li").css("border", "1px solid #20a0ff");
$("#videoName").text(fileObj.name);
} else {
alert("请选择文件");
}
}
/*点击提交*/
function sub() {
var fileObj = document.getElementById("file").files[0]; // js 获取文件对象
if (fileObj == undefined || fileObj == "") {
alert("请选择文件");
@ -234,7 +227,7 @@
}
var url = "mgt/upload"; // 接收上传文件的后台地址
var form = new FormData(); // FormData 对象
form.append("mf",fileObj); // 文件对象
form.append("mf", fileObj); // 文件对象
xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
xhr.open("post", url, true); //post方式url为服务器请求地址true 该参数规定请求是否异步处理。
xhr.onload = uploadComplete; //请求完成
@ -245,7 +238,12 @@
oloaded = 0; //设置上传开始时以上传的文件大小为0
};
xhr.send(form); //开始上传发送form数据
} else {
alert("请选择文件");
}
}
//上传进度实现方法,上传过程中会频繁调用该方法
function progressFunction(evt) {