/
index.html
275 lines (242 loc) · 11.7 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
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Anis Ahmad <anis.programmer@gmail.com>">
<title>Bootstrap File Field (jQuery Plugin)</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" type="text/css" href="../bower_components/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="../bower_components/bootstrap/dist/css/bootstrap-theme.css">
<link rel="stylesheet" type="text/css" href="../src/css/bootstrap_file_field.css">
<!-- Custom styles for this template -->
<link href="css/style.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<div class="header">
<ul class="nav nav-pills pull-right">
<li><a href="https://github.com/ajaxray/bootstrap-file-field">Home</a></li>
<li class="active"><a href="#">Demo</a></li>
</ul>
<h3 class="text-muted">Bootstrap File Filed</h3>
</div>
<div class="col-md-12">
<h3>Bootstrap File Field demo</h3>
<p class="lead">
Examples of using and configuring <i>Bootstrap File Field</i> in various ways.
</p>
<p class="text-info"><strong>Note:</strong> On server end, you'll receive the files with submitted form (with <code>enctype="multipart/form-data"</code>).
No ajax upload is being used.</p>
<hr>
<form role="form" enctype="multipart/form-data">
<!--<div class="form-group">-->
<!--<label for="photo" class="col-sm-3 control-label">Upload photos</label>-->
<!--<div class="col-sm-9 fileinput">-->
<!--<span class="file-input btn btn-primary btn-file">-->
<!--Select Files <input type="file" name="photo[]" data-file-types="image/jpeg,image/png,image/gif" multiple>-->
<!--</span>-->
<!--<p><small>You can select multiple files. Only jpeg, png and gif images are acceptable.</small></p>-->
<!--<ul class="list-unstyled fileList"></ul>-->
<!--</div>-->
<!--</div>-->
<div class="form-group">
<label for="sample1">Example 1: Initiating with data attribute, no customization</label>
<p>
<code><input type="file" data-field-type="bootstrap-file-filed" name="sample1"></code>
</p>
<input type="file" data-field-type="bootstrap-file-filed" name="sample1">
</div>
<div class="form-group">
<label for="sample2">Example 2: Single Image file with preview.</label>
<p>
<code><input type="file" name="sample2" data-field-type="bootstrap-file-filed" <br />
data-preview="on" <br />
data-file-types="image/jpeg,image/png,image/gif"></code>
</p>
<input type="file" name="sample2"
data-field-type="bootstrap-file-filed"
data-file-types="image/jpeg,image/png,image/gif"
data-preview="on">
</div>
<div class="form-group">
<label for="sample3">Example 3: Showing image preview, setting custom label, class and file types. Allows multiple.</label>
<p>
<code><input type="file" name="sample3[]" data-field-type="bootstrap-file-filed" <br />
data-label="Select Image Files" <br />
data-btn-class="btn-primary" <br />
data-file-types="image/jpeg,image/png,image/gif" <br />
data-preview="on" <br />
multiple >
</code>
</p>
<input type="file" name="sample3[]"
data-field-type="bootstrap-file-filed"
data-label="Select Image Files"
data-btn-class="btn-primary"
data-file-types="image/jpeg,image/png,image/gif"
data-preview="on"
multiple
>
</div>
<div class="form-group">
<label for="sample4">Example 4: Allow PDF files only. Preview off.</label>
<p>
<code><input type="file" name="sample4[]" data-field-type="bootstrap-file-filed" <br />
data-label="Select PDF Files" <br />
data-file-types="application/pdf" <br />
multiple >
</code>
</p>
<input type="file" name="sample4[]"
data-field-type="bootstrap-file-filed"
data-label="Select PDF Files"
data-file-types="application/pdf"
multiple
>
</div>
<div class="form-group">
<label for="sample5">Example 5: Initiating with javascript by class/selector. Select at most 2 images below 80kb each.</label>
<p>
HTML : <br />
<code><input type="file" class="smart-file" name="sample3[]" multiple></code><br>
JavaScript <br />
<code>
$('.smart-file').bootstrapFileField({ <br />
maxNumFiles: 2, <br />
fileTypes: 'image/jpeg,image/png', <br />
maxFileSize: 80000 <span class="text-muted">// 80kb in bytes</span> <br />
});
</code>
</p>
<input type="file" name="sample3[]" class="smart-file" multiple>
</div>
<div class="form-group">
<label for="sample6">Example 6: Overwriting initial (by javascript) configuration using data attribute</label>
<p>
This field has already been initiated with previous example (as it has class <code>smart-file</code>).
Now we'll add and modify some of customization options using data attributes.
</p>
<p>
<code>
<input type="file" name="sample6[]" class="smart-file" multiple <br />
data-label="Select PDF Documents" <br />
data-btn-class="btn-primary" <br />
data-file-types="application/pdf">
</code>
</p>
<input type="file" name="sample6[]" class="smart-file" multiple
data-label="Select PDF Documents"
data-btn-class="btn-primary"
data-file-types="application/pdf">
<p><small><b>Help message:</b> You can select multiple files. Only PDF files under 80kb are acceptable.</small></p>
</div>
<div class="form-group">
<button type="submit" class="btn btn-default" disabled>Submit</button>
</div>
</form>
</div>
<p class="clearfix"></p><hr>
<div class="row marketing">
<div class="col-md 12">
<h4>Configuration Options</h4>
<p>You can activate plugin on a file field by adding attribute
<code>data-field-type="bootstrap-file-field"</code> or using javascript (see examples above).
Then you can use the following settings keys (as parameter to javascript activation function)
or data attributes to configure your file field.
</p>
<table class="table table-bordered">
<tr>
<th>What to configure</th>
<th>JS Settings key</th>
<th>Data attribute</th>
<th>Default</th>
</tr>
<tr>
<td>Button label</td>
<td>label</td>
<td>data-label</td>
<td>
Select File <br />
Select Files <sup>M</sup>
</td>
</tr>
<tr>
<td>Button class</td>
<td>btnClass</td>
<td>data-btn-class</td>
<td>btn-default</td>
</tr>
<tr>
<td>
Allowed file types by <a href="https://www.sitepoint.com/web-foundations/mime-types-complete-list/" target="_blank">mime type</a>
<br>(comma separated values)
</td>
<td>fileTypes</td>
<td>data-file-types</td>
<td><em>Ignored</em></td>
</tr>
<tr>
<td>Preview thumb</td>
<td>preview</td>
<td>data-preview</td>
<td>off</td>
</tr>
<tr>
<td>Maximum file size (in byte)</td>
<td>maxFileSize</td>
<td>data-max-file-size</td>
<td><em>Ignored</em></td>
</tr>
<tr>
<td>Minimum file size (in byte)</td>
<td>minFileSize</td>
<td>data-min-file-size</td>
<td><em>Ignored</em></td>
</tr>
<tr>
<td>Maximum total file size <sup>M</sup></td>
<td>maxTotalSize</td>
<td>data-max-total-size</td>
<td><em>Ignored</em></td>
</tr>
<tr>
<td>Maximum number of files <sup>M</sup></td>
<td>maxNumFiles</td>
<td>data-max-num-files</td>
<td><em>Ignored</em></td>
</tr>
<tr>
<td>Minimum number of files <sup>M</sup></td>
<td>minNumFiles</td>
<td>data-min-num-files</td>
<td><em>Ignored</em></td>
</tr>
</table>
<p><sup>M</sup> = For multiple file <selection></selection></p>
</div>
</div>
<div class="footer">
<p>© ajaxray.com 2016</p>
</div>
</div> <!-- /container -->
<script type="text/javascript" src="../bower_components/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="../src/js/bootstrap_file_field.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.smart-file').bootstrapFileField({
maxNumFiles: 2,
fileTypes: 'image/jpeg,image/png',
maxFileSize: 800000 // 80kb in bytes
});
});
</script>
</body>
</html>