-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
77 lines (61 loc) · 1.73 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
$(function ready() {
$(':file').on('change', function () {
var file = this.files[0];
if (file.size > 1024) {
//alert('max upload size is 1k');
console.info('more than 1k');
}
// Also see .name, .type
});
$(':button').on('click', function () {
$.ajax({
// Your server script to process the upload
url: '/',
type: 'POST',
// Form data
data: new FormData($('form')[0]),
// Tell jQuery not to process data or worry about content-type
// You *must* include these options!
cache: false,
contentType: false,
processData: false,
// Custom XMLHttpRequest
xhr: function () {
var myXhr = $.ajaxSettings.xhr();
if (myXhr.upload) {
// For handling the progress of the upload
myXhr.upload.addEventListener('progress', function (e) {
if (e.lengthComputable) {
$('progress').attr({
value: e.loaded,
max: e.total,
});
}
}, false);
}
return myXhr;
}
});
});
var recorder = document.getElementById('recorder');
/*
recorder.addEventListener('change', function(e) {
var file = e.target.files[0];
// Do something with the video file.
var dataUrl = URL.createObjectURL(file);
// convert base64/URLEncoded data to raw binary data held in a string
var blob = dataURItoBlob(dataUrl);
// SimpleHTTPServerWithUpload is expecting a "File"
var fileOfBlob = new File([blob], 'testSave.png');
// add the file to a form
var formData = new FormData();
formData.append("file", fileOfBlob);
// send it
//
var url = "http://localhost:8000";
var httpPost = new XMLHttpRequest();
httpPost.open("POST", url, true);
httpPost.send(formData);
});
*/
});