This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0
wcui/js/lib/uploader/index.html

62 lines
1.6 KiB
HTML
Raw Normal View History

2017-03-30 01:40:59 +08:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Examples</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="../css/base.min.css" rel="stylesheet">
<style type="text/css">
.preview {width:500px;height:300px;margin:auto;border:1px solid #ddd;}
</style>
</head>
<body ms-controller="test">
<div class="preview">
<img ms-attr-src="preview">
</div>
<input type="file" ms-duplex="file" id="file">
<a href="javascript:;" class="submit">提交</a>
<script src="../avalon.modern.js"></script>
<script type="text/javascript">
require(['uploader/uploader', 'ajax/ajax.min'], function(Up){
var uploader = new Up()
uploader.setUrl('http://up.qbox.me')
.onProgress(function(obj){
console.log(obj.speed, obj.progress, obj.loaded, obj.time)
})
.onEnd(function(res){
console.info(res)
})
var submit = document.querySelector('.submit')
var file = document.querySelector('#file')
submit.onclick = function(){
// console.log(file.files[0])
avalon.get('/upload.php?image=' + file.files[0].name, '', function(txt){
uploader.init()
.setField('file', file.files[0])
.setField('token', txt)
.setField('key', 'avatar/dsfghj')
.start()
}, 'text')
}
})
</script>
</body>
</html>