hyperf-chat/upload-test.html

38 lines
957 B
HTML
Raw Normal View History

2020-11-03 17:12:57 +08:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<input type="file" name="filename" id="upload-btn"/>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript">
$('#upload-btn').on('change', function (file) {
var file = $(this)[0].files[0];
var fileData = new FormData();
fileData.append("file", file);
var i = 0;
var func = function () {
2020-11-04 07:54:11 +08:00
if (i >= 2000) {return;}
2020-11-03 17:12:57 +08:00
$.ajax({
2020-11-04 07:54:11 +08:00
url: 'http://127.0.0.1:9503/upload',
2020-11-03 17:12:57 +08:00
data: fileData,
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
processData: false,
success: function () {
2020-11-04 07:54:11 +08:00
i++;
2020-11-03 17:12:57 +08:00
func();
}
})
};
func();
});
</script>
</body>
</html>