-
Notifications
You must be signed in to change notification settings - Fork 0
/
brand-add.php
70 lines (63 loc) · 3.06 KB
/
brand-add.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
<?=template_header("Insert brands")?>
<div class="container">
<div class="my-form">
<div class="row justify-content-center">
<div class="col-sm-10">
<div class="card">
<div class="card-header">
<h1 class="card-title">Blagovna znamka</h1>
</div><!-- card-heaaer -->
<div class="card-body">
<form method="post" class="content" action="./index.php?page=src/inc/brand-insert.inc" enctype="multipart/form-data">
<h2 class="segmant-name">Ime blagovne znamke</h2>
<hr/>
<div class="form-group">
<label class="col-md-4 col-form-label text-md-left" for="title"></label>
<div class="col">
<input type="text" name="title" class="form-control" id="title" maxlength="120" placeholder="Ime blagovne znamke" onkeyup="countChar(this)" required>
<span id="charNum" class="text-right">Na voljo je še: 120 znakov</span>
</div><!-- col -->
</div>
<div class="form-group">
<label class="col-md-4 col-form-label text-md-left" for="image">Slika</label>
<input type="file" name="image" class="form-control" id="image" max="1" required>
<div id="preview"></div>
</div><!-- form-group -->
<div class="col-md-3 offset-md-2 float-right float-sm-right">
<button type="submit" name="submit" class="btn btn-primary" id="brand-insert">Dodaj</button>
</div><!-- col-md-3 offset-md-2 float-righ float-sm-right -->
</form>
</div><!-- card-body -->
</div><!-- card -->
</div><!-- col-sm-10 -->
</div><!-- row justify-content-center -->
</div><!-- my-form -->
</div><!-- container -->
<?=template_footer()?>
<script>
function countChar(val) {
var len = val.value.length;
if (len >= 121) {
val.value = val.value.substring(0, 120);
} else {
$('#charNum').text('Na voljo je še: ' + (120 - len) + ' znakov.');
}
};
</script>
<script>
function previewImages() {
var $preview = $('#preview').empty();
if (this.files) $.each(this.files, readAndPreview);
function readAndPreview(i, file) {
if (!/\.(jpe?g|png|gif)$/i.test(file.name)){
return alert(file.name +" is not an image");
} // else...
var reader = new FileReader();
$(reader).on("load", function() {
$preview.append($("<img/>", {src:this.result, height:100}));
});
reader.readAsDataURL(file);
}
}
$('#image').on("change", previewImages);
</script>