-
Notifications
You must be signed in to change notification settings - Fork 100
/
Copy pathvalidators.html
52 lines (47 loc) · 1.19 KB
/
validators.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
51
52
<meta charset="UTF-8" />
<meta content="width=device-width,initial-scale=1" name="viewport"/>
<script>
UPLOADCARE_PUBLIC_KEY = 'demopublickey'
UPLOADCARE_TABS = 'default huddle'
UPLOADCARE_DEBUG_UPLOADS = true
</script>
<script src="./uploadcare.full.js"></script>
<script>
$ = uploadcare.jQuery
jQuery = uploadcare.jQuery
</script>
<p>
images only, 500kb max<br />
<input type="hidden" data-preview-step role="uploadcare-uploader" />
</p>
<script>
UPLOADCARE_PUBLIC_KEY = '3a8b645aef4a1b959b88'
UPLOADCARE_LOCALE_TRANSLATIONS = {
// messages for widget
errors: { fileSize: 'File is too large.' },
// messages for dialog’s error page
dialog: {
tabs: {
preview: {
error: {
fileSize: {
title: 'Error.',
text: 'File is too large.',
back: 'Back'
}
}
}
}
}
}
function fileSizeCheck(fileInfo) {
if (fileInfo.size !== null) {
if (fileInfo.size > 1024 * 1024) {
console.log('err')
throw new Error('fileSize')
}
}
}
var widget = uploadcare.Widget('[role=uploadcare-uploader]')
widget.validators.push(fileSizeCheck)
</script>