forked from fyneworks/multifile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docs.html
1106 lines (1010 loc) · 40.3 KB
/
docs.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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html><html><head><title>jQuery MultiFile v2.2.1</title><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.1.1-1/css/custom/bootstrap.min.css"><link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css"><link rel="stylesheet" href="docs.css"><script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script><script src="http://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script><script src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.1.1/js/bootstrap.min.js"></script><link rel="stylesheet" href="http://prismjs.com/themes/prism.css"><script src="http://prismjs.com/prism.js"></script><!--link(rel='stylesheet', href='http://highlightjs.org/static/styles/zenburn.css')--><!--script(src='http://yandex.st/highlightjs/8.0/highlight.min.js')--><script src="docs.js"></script></head><body><div role="navigation" class="navbar navbar-default navbar-fixed-top navbar-static-top"><div class="container"><div class="navbar-header"><button type="button" data-toggle="collapse" data-target=".navbar-collapse" class="navbar-toggle"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a href="./" class="navbar-brand">jQuery MultiFile</a></div><div class="navbar-collapse collapse"><ul class="nav navbar-nav"><!--lia(href='#') Intro--><li><a href="#Usage" id="#btn-Usage">Usage</a></li><li><a href="#Advanced" id="#btn-Advanced">Advanced</a></li><li><a href="#Customize" id="#btn-Customize">Customize</a></li><li><a href="#Events" id="#btn-Events">Events</a></li><li><a href="#Locale" id="#btn-Locale">Locale</a></li><li><a href="#Install" id="#btn-Install">Install</a></li><li><a href="#Support" id="#btn-Support">Support</a></li><li><a href="#Credit" id="#btn-Credit">Credit</a></li></ul></div></div></div><div class="container"><div class="jumbotron"><h1>jQuery MultiFile</h1><p>The <strong>unopinionated</strong> way to implement file selection.</p></div></div><div class="container"><div class="Clear" id="body">
<div class="container clear section">
<div class="row">
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<h3>What
<span style="color:green;">this is</span>
</h3>
<p>
This
<strong>jQuery Multiple File Selection Plugin</strong>
(<code>$.MultiFile</code>) is a non-obstrusive plugin for <a href="http://www.jquery.com/">jQuery</a>
that helps users easily
<strong>select multiple files</strong> for upload. It lets you apply some basic restrictions/validation so you can easily
<strong>reject files before they're uploaded</strong> based on their extension or size
<strong>before they're uploaded</strong>.
</p>
</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<h3>What <span style="color:red;">this isn't</span></h3>
<p>
<strong class="warning">This is not a file upload tool</strong>. Uploading files require
<strong>server-side integration</strong> and
<strong>security considerations</strong>
this project will never support. We can recommend
<a href="http://www.uploadify.com/" target="_blank">many</a>,
<a href="http://www.plupload.com/" target="_blank">many</a>,
<strong><a href="http://blueimp.github.io/jQuery-File-Upload/" target="_blank">many</a>
</strong>
great tools if you're looking for a complete upload solution. But if you don't already manage your own server-side integration, or if you have no idea what I'm talking about, then this plugin is not for you.
</p>
</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<h3>What's new?</h3>
<p>
<strong>A fresh start... <em>ish</em>
</strong>: This project started a a very long time ago... and it's been dormant since 2009! Support has been shockingly bad, we admit, but we would like to engage more actively with our users and the jQuery community from now on. So as of April 2014, we've left <a href="https://code.google.com/p/jquery-fyneworks/" target="_blank">Google Code</a> behind and will be starting a fresh project on <a target="_blank" href="https://github.com/fyneworks/multifile">GitHub</a>. Our other projects (<a href="http://www.fyneworks.com/jquery/star-rating">Star Rating</a> & <a href="http://www.fyneworks.com/jquery/CKEditor">CKEditor</a> will follow shortly). We very much encourage and would love you all to report issues, contribue and discuss this project on <a target="_blank" href="https://github.com/fyneworks/multifile">GitHub</a>.
</p>
</div>
</div>
<h3>Getting started</h3>
<div class="row example">
<div class="col-md-8">
<p>
Just add the
<code><strong>multi</strong></code> class to your file input element.
</p>
<pre><code class="language-markup"><input type="file" class="multi"/></code></pre>
</div>
<div class="col-md-4">
<input type="file" multiple="multiple" class="multi" multiple="multiple" />
</div>
</div>
<div class="row example">
<div class="col-md-8">
<p>
Use the
<code><strong>maxlength</strong></code> property if you want to limit the number of files selected.
</p>
<pre><code class="language-markup"><input type="file" class="multi" maxlength="2"/></code></pre>
</div>
<div class="col-md-4">
<input type="file" multiple="multiple" class="multi" maxlength="2" />
</div>
</div>
<div class="row example">
<div class="col-md-8">
<p>
Use the
<code><strong>accept</strong></code> property if you only want files of a certain extension to be selected.
<br/>
Separate valid extensions with a "|", like this: "jpg|gif|png".
</p>
<pre><code class="language-markup"><input type="file" class="multi" accept="gif|jpg"/></code></pre>
</div>
<div class="col-md-4">
<input type="file" multiple="multiple" class="multi" accept="gif|jpg" />
</div>
</div>
<div class="row example">
<div class="col-md-8">
NB.: <span style="font-weight:bold; color:red;">server-side validation is always required</span>
</div>
</div>
</div>
<div class="container clear section" id="Usage">
<h2>Usage Examples</h2>
<div class="example">
<h3>Using Attributes</h3>
<div class="row">
<div class="col-md-12">
<p>The easiest way to get started is to add <code>class="multi"</code> and modify the attributes of your element</p>
</div>
</div>
<div class="row">
<div class="col-md-4">
<fieldset style="border:0">
<legend>
<strong>Example 1</strong>
</legend>
<p>Use <code>maxlength</code> to limit the number of files selected</p>
<pre><code class="language-markup"><input
class="multi"
maxlength="2"
/></code></pre>
<div class="P5 B">
Limit: 2 files.
<br/>Allowed extensions: any.
</div>
<form action="" class="P10">
<input type="file" multiple="multiple" class="multi" maxlength="2" />
</form>
</fieldset>
</div>
<div class="col-md-4">
<fieldset style="border:0">
<legend>
<strong>Example 2</strong>
</legend>
<p>Use <code>accept</code> to limit the extensions allowed</p>
<pre><code class="language-markup"><input
class="multi"
accept="gif|jpg"
/></code></pre>
<div class="P5 B">
Limit: no limit.
<br/>Allowed extensions: gif and jpg.
</div>
<form action="" class="P10">
<input type="file" multiple="multiple" class="multi" accept="gif|jpg" />
</form>
</fieldset>
</div>
<div class="col-md-4">
<fieldset style="border:0">
<legend>
<strong>Example 3</strong>
</legend>
<p>Use <code>maxlength</code> and <code>accept</code> combined</p>
<pre><code class="language-markup"><input
class="multi"
accept="gif|jpg"
maxlength="3"
/></code></pre>
<div class="P5 B">
Limit: 3 files
<br/>Allowed extensions: gif, jpg.
</div>
<form action="" class="P10">
<input type="file" multiple="multiple" class="multi" accept="gif|jpg" maxlength="3" />
</form>
<div class="P5 Warning Bold">
Note that server-side validation is always required
</div>
</fieldset>
</div>
</div>
</div>
<div class="example">
<h3>Using the <code>class</code> property</h3>
<div class="row">
<div class="col-md-12">
<p>There is a way to configure the plugin via the <code>class</code> property, without any knowledge of javascript</p>
</div>
</div>
<div class="row">
<div class="col-md-4">
<fieldset style="border:0">
<legend>
<strong>Example 4</strong>
</legend>
<pre><code class="language-markup"><input class="
multi max-3
"/></code></pre>
<div class="P5 B">
Limit: 3 files.
<br/>Allowed extensions: any.
</div>
<form action="" class="P10">
<input type="file" multiple="multiple" class="multi max-3" />
</form>
</fieldset>
</div>
<div class="col-md-4">
<fieldset style="border:0">
<legend>
<strong>Example 5</strong>
</legend>
<pre><code class="language-markup"><input class="
multi accept-gif|jpg
"/></code></pre>
<div class="P5 B">
Limit: no limit.
<br/>Allowed extensions: gif, jpg.
</div>
<form action="" class="P10">
<input type="file" multiple="multiple" class="multi accept-gif|jpg" />
</form>
</fieldset>
</div>
<div class="col-md-4">
<fieldset style="border:0">
<legend>
<strong>Example 6</strong>
</legend>
<pre><code class="language-markup"><input class="
multi
max-3
accept-gif|jpg
maxsize-1024
"/></code></pre>
<div class="P5 B">
Limit: 3 files
<br/>Allowed extensions: gif, jpg.
<br/>Max payload: 1MB (1024 bytes)
</div>
<form action="" class="P10">
<input type="file" multiple="multiple" class="multi max-3 accept-gif|jpg maxsize-1024" />
</form>
<div class="P5 Warning Bold">
Note that server-side validation is always required
</div>
</fieldset>
</div>
</div>
</div>
<div class="example">
<h3>Selecting many files at once (HTML5)</h3>
<div class="row">
<div class="col-md-12">
<p>So far, each of the example above has only enabled you to select one file at a time. To select multiple files at once, just use HTML5's <code>multiple</code> attribute (<a href="http://www.w3schools.com/tags/att_input_multiple.asp">1</a>, <a href="http://www.w3.org/TR/2012/WD-html5-20121025/common-input-element-attributes.html#attr-input-multiple">2</a>)</p>
</div>
</div>
<div class="row">
<div class="col-md-4">
<fieldset style="border:0">
<legend>
<strong>Example 7</strong>
</legend>
<pre><code class="language-markup"><input
multiple
class="multi"
maxlength="10"
/></code></pre>
<div class="P5 B">
Limit: 10 files.
<br/>Allowed extensions: any.
</div>
<form action="" class="P10">
<input type="file" multiple="multiple" class="multi" maxlength="10"/>
</form>
</fieldset>
</div>
<div class="col-md-4">
<fieldset style="border:0">
<legend>
<strong>Example 8</strong>
</legend>
<pre><code class="language-markup"><input
multiple
class="multi"
accept="gif|jpg|png"
/></code></pre>
<div class="P5 B">
Limit: no limit.
<br/>Allowed extensions: gif, jpg.
</div>
<form action="" class="P10">
<input type="file" multiple="multiple" class="multi" accept="gif|jpg|png"/>
</form>
</fieldset>
</div>
<div class="col-md-4">
<fieldset style="border:0">
<legend>
<strong>Example 9</strong>
</legend>
<pre><code class="language-markup"><input
multiple
class="multi"
maxlength="10"
accept="gif|jpg|png"
/></code></pre>
<div class="P5 B">
Limit: 10 files
<br/>Allowed extensions: gif, jpg, png.
</div>
<form action="" class="P10">
<input type="file" multiple="multiple" class="multi" maxlength="10" accept="gif|jpg|png"/>
</form>
<div class="P5 Warning Bold">
Note that server-side validation is always required
</div>
</fieldset>
</div>
</div>
</div>
<div class="example">
<h3>Validating Sizes</h3>
<div class="row">
<div class="col-md-12">
<p>It's common to validate the size of the files being selected prior to upload.</p>
</div>
</div>
<div class="row">
<div class="col-md-4">
<fieldset style="border:0">
<legend>
<strong>Example 10a</strong>
</legend>
<p>Using class <code>maxsize-*</code> (* = max size in kb)</code></p>
<pre><code class="language-markup"><input
multiple
class="multi maxsize-5120"
/></code></pre>
<div class="P5 B">
Limit: any number of files
<br/>Allowed extensions: any.
<br/>Max payload: 5MB
</div>
<form action="" class="P10">
<input type="file" multiple="multiple" class="multi maxsize-5120"/>
</form>
</fieldset>
</div>
<div class="col-md-4">
<fieldset style="border:0">
<legend>
<strong>Example 10b</strong>
</legend>
<p>Using <code>data-maxsize</code> attribute (max size in kb)</p>
<pre><code class="language-markup"><input
multiple
class="multi"
maxlength="3"
data-<strong>maxsize</strong>="1024"
/></code></pre>
<div class="P5 B">
Limit: 3 files (under <1MB <strong>in total</strong>)
</div>
<form action="" class="P10">
<input type="file" multiple="multiple" class="multi" maxlength="3" data-maxsize="1024" />
</form>
</fieldset>
</div>
<div class="col-md-4">
<fieldset style="border:0">
<legend>
<strong>Example 10c</strong>
</legend>
<p>Use <code>data-maxfile</code> to validate individual files</p>
<pre><code class="language-markup"><input
multiple
class="multi"
maxlength="3"
data-<strong>maxfile</strong>="1024"
/></code></pre>
<div class="P5 B">
Limit: 3 files (under <1MB <strong>each</strong>)
</div>
<form action="" class="P10">
<input type="file" multiple="multiple" class="multi" maxlength="3" data-maxfile="1024" />
</form>
<div class="P5 Warning Bold">
Note that server-side validation is always required
</div>
</fieldset>
</div>
</div>
<div class="example">
<h3>With an Image Preview</h3>
<div class="row">
<div class="col-md-12">
<p>There's an easy way to add a preview of the image being uploaded</p>
</div>
</div>
<div class="row">
<div class="col-md-4">
<fieldset style="border:0">
<legend>
<strong>Example 11a</strong>
</legend>
<p>Using class <code>with-preview</code></p>
<pre><code class="language-markup"><input
multiple
class="multi with-preview"
/></code></pre>
<form action="" class="P10">
<input type="file" multiple="multiple" class="multi with-preview"/>
</form>
</fieldset>
</div>
</div>
</div>
<div class="container clear section" id="Advanced">
<h2>Advanced Examples</h2>
<div class="row">
<div class="col-md-12">
<div style="margin:10px 0; background-color:#ececec color:#f00; padding:10px; border:#ccc dotted 1px; color:#f00; font-weight:bold;">
IMPORTANT: Don't use <code>class="multi"</code> if you use any of the examples below this point.
</div>
</div>
<div class="col-md-12">
<p>
If you use <code><strong>class="multi"</strong></code> the plugin will be initialised automatically
(taking precedence over your code).
</p>
<p>
You must invoke the plugin with your own selector when you use any of the examples below.
</p>
</div>
<div class="col-md-6">
Something like
<pre><code class="language-markup"><input type="file" class="<strong>this-is-your-class</strong>" /></code></pre>.
</div>
<div class="col-md-6">
Followed by
<pre><code class="language-javascript">// this is your code
$(function(){ // wait for page to load
// this is your selector
$('input.<strong>this-is-your-class</strong>').MultiFile({
// your options go here
max: 2,
accept: 'jpg|png|gif'
});
});</code></pre>
</p>
</div>
</div>
<div class="example">
<div class="row">
<div class="col-md-4">
<h3>Setting limit via script</h3>
<pre><code class="language-markup"><input multiple type="file" id="UpTo3Files"/></code></pre>
<pre><code class="language-javascript">// wait for document to load
$(function(){
// up to 3 files can be selected
// invoke plugin
$('#UpTo3Files').MultiFile(5);
// if you send in a number the plugin
// will treat it as the file limit
});</code></pre>
<div>
Try it:
<input multiple type="file" id="UpTo3Files"/>
<script>$(function(){
// up to 5 files can be selected
// invoke plugin
$('#UpTo3Files').MultiFile(3);
// if you send in a number the plugin
// will treat it as the file limit
});</script>
</div>
</div>
<div class="col-md-4">
<h3>Limit and Extension Filter</h3>
<pre><code class="language-markup"><input multiple type="file" id="UpTo3Images"/></code></pre>
<pre><code class="language-javascript">// wait for document to load
$(function(){
// up to 3 files can be selected
// only images are allowed
// invoke plugin
$('#UpTo3Images').MultiFile({
max: 3,
accept: 'gif|jpg|png'
});
});</code></pre>
<div>
Try it:
<input multiple type="file" id="UpTo3Images"/>
<script>$(function(){
// up to 5 files can be selected
// only images are allowed
// invoke plugin
$('#UpTo3Images').MultiFile({
max: 3,
accept: 'gif|jpg|png'
});
});</script>
</div>
</div>
<div class="col-md-4">
<h3>Multi-lingual support</h3>
<pre><code class="language-markup"><input multiple type="file" id="EmPortugues"/></code></pre>
<pre><code class="language-javascript">// wait for document to load
$(function(){
// use a different language
// $file prints the file name
// $ext prints the file extension
// invoke plugin
$('#EmPortugues').MultiFile({
max: 3,
accept: 'gif|jpg|png'
STRING: {
remove:'Remover',
selected:'Selecionado: $file',
denied:'Invalido arquivo de tipo $ext!'
}
});
});</code></pre>
<div>
Try it:
<input multiple type="file" id="EmPortugues"/>
<script>$(function(){
// use a different lanague
// $file prints the file name
// $ext prints the file extension
// invoke plugin
$('#EmPortugues').MultiFile({
max: 3,
accept: 'gif|jpg|png',
STRING: {
remove:'Remover',
selected:'Selecionado: $file',
denied:'Invalido arquivo de tipo $ext!'
}
});
});</script>
</div>
</div>
</div><!-- row -->
</div><!-- example -->
<div class="example">
<h3>Moving the file list</h3>
<div class="row">
<div class="col-md-8">
<fieldset style="border:0">
<!--
<legend>
<strong>Example 7</strong>
</legend>
-->
<p>This example populates the file list in a custom element</p>
<pre><code class="language-javascript">$(function() { // wait for document to load
$('#T7').MultiFile({
list: '#T7-list'
});
});</code></pre>
<script type="text/javascript" language="javascript">
$(function() { // wait for document to load
$('#T7').MultiFile({
list: '#T7-list'
});
});
</script>
</fieldset>
</div>
<div class="col-md-4">
<form action="" class="P10">
<input type="file" id="T7" />
</form>
<div id="T7-list" style="border:#999 solid 3px; padding:10px;">
This is div#T7-list - selected files will be populated here...
<br/>
<br/>
</div>
</div>
</div><!-- row -->
</div><!-- example -->
<div class="example" id="Customize">
<h3>Customising the file list</h3>
<div class="row">
<div class="col-md-8">
<fieldset style="border:0">
<!--
<legend>
<strong>Example 8 A</strong>
</legend>
-->
<p>Use a custom 'remove' image in the file list</p>
<pre><code class="language-javascript">$(function() { // wait for document to load
$('#T8A').MultiFile({
STRING: {
remove: '<img src="/i/bin.gif" height="16" width="16" alt="x"/>'
}
});
});</code></pre>
<script type="text/javascript" language="javascript">
$(function() { // wait for document to load
$('#T8A').MultiFile({
STRING: {
remove: '<img src="/i/bin.gif" height="16" width="16" alt="x"/>'
}
});
});
</script>
</fieldset>
</div>
<div class="col-md-4">
<form action="" class="P10">
<input type="file" id="T8A" />
</form>
</div>
</div><!-- row -->
</div><!-- example -->
<div class="example">
<div class="row">
<div class="col-md-8">
<fieldset style="border:0">
<!--
<legend>
<strong>Example 8 B</strong>
</legend>
-->
<p>Customising all list content</p>
<pre><code class="language-javascript">$(function() { // wait for document to load
$('#T8B').MultiFile({
STRING: {
file: '<em title="Click to remove" onclick="$(this).parent().prev().click()">$file</em>',
remove: '<img src="/i/bin.gif" height="16" width="16" alt="x"/>'
}
});
});</code></pre>
<script type="text/javascript" language="javascript">
$(function() { // wait for document to load
$('#T8B').MultiFile({
STRING: {
file: '<em title="Click to remove" onclick="$(this).parent().prev().click()">$file</em>',
remove: '<img src="/i/bin.gif" height="16" width="16" alt="x"/>'
}
});
});
</script>
</fieldset>
</div>
<div class="col-md-4">
<form action="" class="P10">
<input type="file" id="T8B" />
</form>
</div>
</div><!-- row -->
</div><!-- example -->
<div class="example" id="Events">
<h3>Using events</h3>
<div class="container">
<div class="row">
<div class="col-md-6">
<p>
The arguments passed on to each event handler are:
<br/>element: file element which triggered the event
<br/>value: the value of the element in question
<br/>master_element: the original element containing all relevant settings
</p>
</div>
<div class="col-md-3">
<p>
Selection events:
<ul>
<li>onFileAppend</li>
<li>afterFileAppend</li>
<li>onFileSelect</li>
<li>afterFileSelect</li>
<li>onFileRemove</li>
<li>afterFileRemove</li>
</ul>
</p>
</div>
<div class="col-md-3">
<p>
Validation events:
<ul>
<li>onFileDuplicate</li>
<li>onFileInvalid</li>
<li>onFileTooMany</li>
<li>onFileTooBig</li>
<li>onFileTooMuch</li>
</ul>
</p>
</div>
</div>
<div class="row">
<div class="col-md-6">
<fieldset style="border:0">
<!--
<legend>
<strong>Example 9</strong>
</legend>
-->
<pre><code class="language-markup"><input multiple type="file" id="WithEvents"/></code></pre>
<pre><code class="language-javascript">// wait for document to load
$(function(){
// 2 jpgs under 100kb only
$('#WithEvents').MultiFile({
max: 2,
max_size: 100,
accept: 'jpg|png|gif',
onFileRemove: function(element, value, master_element) {
$('#F9-Log').append('<li>onFileRemove - ' + value + '</li>')
},
afterFileRemove: function(element, value, master_element) {
$('#F9-Log').append('<li>afterFileRemove - ' + value + '</li>')
},
onFileAppend: function(element, value, master_element) {
$('#F9-Log').append('<li>onFileAppend - ' + value + '</li>')
},
afterFileAppend: function(element, value, master_element) {
$('#F9-Log').append('<li>afterFileAppend - ' + value + '</li>')
},
onFileSelect: function(element, value, master_element) {
$('#F9-Log').append('<li>onFileSelect - ' + value + '</li>')
},
afterFileSelect: function(element, value, master_element) {
$('#F9-Log').append('<li>afterFileSelect - ' + value + '</li>')
},
onFileInvalid: function(element, value, master_element) {
$('#F9-Log').append('<li>onFileInvalid - ' + value + '</li>')
},
onFileDuplicate: function(element, value, master_element) {
$('#F9-Log').append('<li>onFileDuplicate - ' + value + '</li>')
},
onFileTooMany: function(element, value, master_element) {
$('#F9-Log').append('<li>onFileTooMany - ' + value + '</li>')
},
onFileTooBig: function(element, value, master_element) {
$('#F9-Log').append('<li>onFileTooBig - ' + value + '</li>')
},
onFileTooMuch: function(element, value, master_element) {
$('#F9-Log').append('<li>onFileTooMuch - ' + value + '</li>')
}
});
});</code></pre>
<script type="text/javascript" language="javascript">
$(function() { // wait for document to load
$('#WithEvents').MultiFile({
max: 2,
max_size: 100,
accept: 'jpg|png|gif',
onFileRemove: function(element, value, master_element) {
$('#F9-Log').append('<li>onFileRemove - ' + value + '</li>')
},
afterFileRemove: function(element, value, master_element) {
$('#F9-Log').append('<li>afterFileRemove - ' + value + '</li>')
},
onFileAppend: function(element, value, master_element) {
$('#F9-Log').append('<li>onFileAppend - ' + value + '</li>')
},
afterFileAppend: function(element, value, master_element) {
$('#F9-Log').append('<li>afterFileAppend - ' + value + '</li>')
},
onFileSelect: function(element, value, master_element) {
$('#F9-Log').append('<li>onFileSelect - ' + value + '</li>')
},
afterFileSelect: function(element, value, master_element) {
$('#F9-Log').append('<li>afterFileSelect - ' + value + '</li>')
},
onFileInvalid: function(element, value, master_element) {
$('#F9-Log').append('<li>onFileInvalid - ' + value + '</li>')
},
onFileDuplicate: function(element, value, master_element) {
$('#F9-Log').append('<li>onFileDuplicate - ' + value + '</li>')
},
onFileTooMany: function(element, value, master_element) {
$('#F9-Log').append('<li>onFileTooMany - ' + value + '</li>')
},
onFileTooBig: function(element, value, master_element) {
$('#F9-Log').append('<li>onFileTooBig - ' + value + '</li>')
}
});
});
</script>
</fieldset>
</div>
<div class="col-md-6">
<form action="" class="P10">
<input multiple type="file" id="WithEvents" />
</form>
<div style="border:#999 solid 3px; padding:10px;">
This is div#F9-Log - selected files will be populated here...
<br/>
<ul id="F9-Log">
</ul>
</div>
</div>
</div>
</div><!-- row -->
</div><!-- example -->
</div>
</div>
</div>
<!--// Usage //-->
<div class="container clear section" id="Locale">
<h2>Multi-lingual support</h2>
<p>
The plugin doesn't have any additional languages built-in, but it's very easy to customise the messages to any language of your choosing. See the examples below...
</p>
<p>
NB.: This example has been configured to accept gif/pg files only in order to demonstrate the error messages.
</p>
<form action="" class="P10">
<input type="file" multiple="multiple" class="multi {accept:'gif|jpg', max:3, STRING: {remove:'Remover',selected:'Selecionado: $file',denied:'Invalido arquivo de tipo $ext!',duplicate:'Arquivo ja selecionado:\n$file!'}}" />
</form>
<h3>Method 1: Using class property (requires the MetaData plugin)</h3>
<pre><code class="language-markup"><input type="file"
class="multi {
accept:'gif|jpg',
max:3,
STRING:{
remove:'Remover',
selected:'Selecionado: $file',
denied:'Invalido arquivo de tipo $ext!',
duplicate:'Arquivo ja selecionado:\n$file!'
}
}"
/></code></pre>
<h3>Method 2: Programatically by ID (ONE element only, does not require MetaData plugin)</h3>
<pre><code class="language-markup"><input type="file" id="PortugueseFileUpload" /></code></pre>
<pre><code class="language-javascript">$(function(){
$('#PortugueseFileUpload').MultiFile({
accept:'gif|jpg',
max:3,
STRING: {
remove:'Remover',
selected:'Selecionado: $file',
denied:'Invalido arquivo de tipo $ext!',
duplicate:'Arquivo ja selecionado:\n$file!'
}
});
});</code></pre>
<h3>Method 3: Programatically (
<em>n</em> emlements, does not require MetaData plugin)</h3>
<a target="_blank" href="http://plugins.jquery.com/node/1251">See this feature request for details</a>
<br/>
<pre><code class="language-markup"><input type="file" class="multi-pt" />
<input type="file" class="multi-pt" />
<input type="file" class="multi-pt" /></code></pre>
<pre><code class="language-javascript">$(function(){
$('.multi-pt').MultiFile({
accept:'gif|jpg',
max:3,
STRING: {
remove:'Remover',
selected:'Selecionado: $file',
denied:'Invalido arquivo de tipo $ext!',
duplicate:'Arquivo ja selecionado:\n$file!'
}
});
});</code></pre>
</div>
<div class="container clear section" id="Install">
<h2>Installation</h2>
<h3>Requirements</h3>
<p>You'll need <a href="http://jquery.com/" target="_blank">jQuery</a>, we recommend using <a href="https://developers.google.com/speed/libraries/devguide#jquery" target="_blank">Google Hosted Libraries</a>.</p>
<pre><code class="language-markup"><script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" type="text/javascript" language="javascript"></script></code></pre>
<h3>The plugin</h3>
<p>
Either <a href="https://github.com/fyneworks/multifile/archive/master.zip">download</a> the latest version and host it on your own server
</p>
<pre><code class="language-markup"><script src="path/to/your/jquery.MultiFile.js" type="text/javascript" language="javascript"></script></code></pre>
<p>
<strong>OR</strong> if you like living <a href="https://www.youtube.com/watch?v=Z0o6hQLcSRc">on the edge</a>, hotlink the latest release directly from <a target="_blank" href="https://github.com/fyneworks/multifile/blob/master/jQuery.MultiFile.min.js">GitHub</a>
</p>
<pre><code class="language-markup"><script src="//github.com/fyneworks/multifile/blob/master/jQuery.MultiFile.min.js" type="text/javascript" language="javascript"></script></code></pre>
</div>
<div class="container clear section" id="Support">
<h2>Support</h2>
<div class="row">
<div class="col-md-12">
<p>
We very much encourage and would love you all to report issues, contribue and discuss this project on <a target="_blank" href="https://github.com/fyneworks/multifile">GitHub</a>.
</p>
<p>
There's also a <a href="README.md">README.md</a> for quick reference, if you're that way inclined.
</p>
<p>
This project started a a very long time ago... and it's been dormant since 2009! Support has been shockingly bad, we admit,
but we would like to engage more actively with our users and the jQuery community from now on. So as of April 2014,
we've left <a href="https://code.google.com/p/jquery-fyneworks/" target="_blank">Google Code</a> behind and
will be starting a fresh project on <a target="_blank" href="https://github.com/fyneworks/multifile">GitHub</a>.
Our other projects (<a href="http://www.fyneworks.com/jquery/star-rating">Star Rating</a> & <a href="http://www.fyneworks.com/jquery/CKEditor">CKEditor</a> will follow shortly).
</p>
</div>
</div>
</div>
<div class="container clear section" id="Credit">
<h2>Credit where it's due!</h2>
<div class="row">
<div class="col-md-12">
<ul>
<li>Fyneworks.com <a href="http://www.fyneworks.com/">professional web design</a> and <a href="http://www.fyneworks.com/">google SEO experts</a>
</li>
<li>Dean Edwards - Author of <a href="http://dean.edwards.name/packer/">JS Packer</a> used to compress the plugin</li>
<li>Adrian Wróbel - Fixed a nasty bug so the script could work perfectly in Opera</li>
<li>Jonas Wagner - Modified plugin so newly created elements are an exact copy of the original element (ie.: persists attributes)</li>
<li>Mike Alsup - Author of several <a href="http://www.malsup.com/jquery/">jQuery Plugins</a>...
<ul>
<li>Suggested solution to element naming convention / server-side handling</li>
<li><a href="http://www.malsup.com/jquery/form/">Form plugin</a> - Used to submit forms via ajax</li>
<li><a href="http://www.malsup.com/jquery/blockUI/">blockUI plugin</a> - Used to show pretty error messages</li>
</ul>
</li>
<li>Julien Phalip - Identified conflict with variable name 'class' in several methods</li>
</ul>
</div>
</div>
</div>
<div class="container clear section" id="License">
<h2>License Info</h2>
<div class="row">
<div class="col-md-12">
<div class="license-info">
<table cellspacing="5" width="100%">
<tr>
<td valign="middle">
<strong>Multiple File Selection Plugin</strong>
by <a href="http://www.fyneworks.com/">Fyneworks.com</a>
is licensed,
<a target="_blank" href="http://jquery.org/license">as jQuery is</a>, under the
<a target="_blank" href="http://en.wikipedia.org/wiki/MIT_License">MIT License</a>.
</td>
<td width="100">
<a target="_blank" href="http://creativecommons.org/licenses/GPL/2.0/">
<img alt="Creative Commons License" style="border-width:0" src="http://creativecommons.org/images/public/somerights20.png" />
</a>
</td>
</tr>