17 Star 29 Fork 4

蓝月萧枫 / AjaxUploadFile

Create your Gitee Account
Explore and code with more than 8 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
demo.html 1.31 KB
Copy Edit Web IDE Raw Blame History
蓝月萧枫 authored 2015-06-11 17:13 . 演示案例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="./js/ajaxUploadFile.js"></script>
<script type="text/javascript">
onload=function(){
document.getElementById("sub").onclick=function(){
var ajaxFile=new uploadFile({
"url":"./up.php",
//"dataType":"text",
"timeout":5000,
"async":true,
"data":{
"name":"lanyue",
"age":100,
"sex":"",
//多文件
"files":{
//file为name字段 后台可以通过$_FILES["file"]获得
"file":document.getElementById("file").files//文件数组
}
//单文件
/*"file":{
"test":document.getElementById("file").files[0],
},*/
},
onloadstart:function(){
//console.log("开始上传");
},
onload:function(data){
console.log(data);
console.log(data.name);
},
onerror:function(er){
console.log(er);
},
onabort:function(){
//alert("取消上传");
},
ontimeout:function(){
alert("上传时间到");
},
onloadend:function(){
alert("上传结束");
},
onprogress:function(e){
console.log(e);
}
});
}
}
</script>
</head>
<body>
<input type="file" value="" multiple="true" id="file">
<input type="button" value="submit" id="sub">
</body>
</html>

Comment ( 0 )

Sign in to post a comment

1
https://git.oschina.net/lanyue/AjaxUploadFile.git
git@git.oschina.net:lanyue/AjaxUploadFile.git
lanyue
AjaxUploadFile
AjaxUploadFile
master

Search

113223 674803ea 1850385 170725 2838fb2a 1850385