forked from jimwins/scat
/
vendor-upload.php
76 lines (72 loc) · 1.94 KB
/
vendor-upload.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?
include 'scat.php';
head("Vendor Upload @ Scat");
?>
<style>
.btn-file {
position: relative;
overflow: hidden;
}
.btn-file input[type=file] {
position: absolute;
top: 0;
right: 0;
min-width: 100%;
min-height: 100%;
font-size: 999px;
text-align: right;
filter: alpha(opacity=0);
opacity: 0;
outline: none;
background: white;
cursor: inherit;
display: block;
}
</style>
<form id="upload-form" method="post"
enctype="multipart/form-data"
action="api/vendor-upload.php">
<input name="vendor" type="hidden" value="">
<div class="form-group">
<label for="vendor">Vendor</label>
<input id="vendor" type="text" class="form-control">
</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-btn">
<button class="btn btn-default btn-file">
Browse <input type="file" name="src">
</button>
</span>
<input type="text" class="form-control" placeholder="Filename" readonly>
</div>
</div>
<button class="btn btn-primary">Upload</button>
</form>
<script>
$('#upload-form #vendor').autocomplete({
source: "./api/person-list.php?callback=?",
minLength: 2,
select: function(ev, ui) {
$("#upload-form input[name='vendor']").val(ui.item.id);
},
});
$(document).on('change', '.btn-file :file', function() {
var input = $(this),
numFiles = input.get(0).files ? input.get(0).files.length : 1,
label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
input.trigger('fileselect', [numFiles, label]);
});
$(document).ready(
function() {
$('.btn-file :file').on('fileselect', function(event, numFiles, label) {
var input = $(this).parents('.input-group').find(':text'),
log = numFiles > 1 ? numFiles + ' files selected' : label;
if( input.length ) {
input.val(log);
} else {
if( log ) displayError(log);
}
});
});
</script>