-
Notifications
You must be signed in to change notification settings - Fork 2
/
demo.blade.php
60 lines (48 loc) · 2.08 KB
/
demo.blade.php
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Test</title>
<link href="https://unpkg.com/filepond/dist/filepond.css" rel="stylesheet">
</head>
<body>
<input type="file" name="file" id="fileInput">
<script src="https://unpkg.com/filepond/dist/filepond.js"></script>
<script>
const pond = FilePond.create(document.querySelector('input[type="file"]'));
pond.setOptions({
server: {
process:(fieldName, file, metadata, load, error, progress, abort) => {
const formData = new FormData();
@foreach(S3BrowserBasedUploads::getFields() as $key => $value)
formData.append('{{ $key }}', '{{ $value }}');
@endforeach
formData.append('Content-Type', file.type);
formData.append(fieldName, file, file.name);
const request = new XMLHttpRequest();
request.open('POST', "{{ S3BrowserBasedUploads::getEndpointUrl() }}");
request.upload.onprogress = (e) => {
progress(e.lengthComputable, e.loaded, e.total);
};
request.onload = function() {
if (request.status >= 200 && request.status < 300) {
load(request.responseText);
}
else {
error('oh no');
}
};
request.send(formData);
return {
abort: () => {
request.abort();
abort();
}
};
}
}
});
</script>
</body>
</html>