-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
50 lines (39 loc) · 1.46 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FilePond Plugin File Encode Demo</title>
<link href="https://unpkg.com/filepond/dist/filepond.css" rel="stylesheet">
</head>
<body>
<!-- The plugin allows adding metadata using data attributes -->
<input type="file" data-file-metadata-foo="bar"/>
<script src="./dist/filepond-plugin-file-metadata.js"></script>
<script src="https://unpkg.com/filepond/dist/filepond.js"></script>
<script>
// Register the plugin with FilePond
FilePond.registerPlugin(FilePondPluginFileMetadata);
// Get a reference to the file input element
const inputElement = document.querySelector('input[type="file"]');
// Create the FilePond instance
const pond = FilePond.create(inputElement, {
// Add metadata using a metadata object property
fileMetadataObject: {
'hello': 'world'
}
});
// Request encoded data
pond.onaddfile = (err, item) => {
if (err) {
console.warn(err);
return;
}
// Get file item metadata
const metadata = item.getMetadata();
// Log the metadata to the console so we can verify it's there
console.log(metadata);
}
</script>
</body>
</html>