62 lines
1.6 KiB
HTML
62 lines
1.6 KiB
HTML
<!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> |
JavaScript
95.2%
CSS
4.8%