-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathform.blade.php
115 lines (79 loc) · 2.83 KB
/
form.blade.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
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
@extends('layout')
@section('css')
<style>
.progress { position:relative; width:100%; border: 1px solid #7F98B2; padding: 1px; border-radius: 3px; }
.bar { background-color: #B4F5B4; width:0%; height:25px; border-radius: 3px; }
.percent { position:absolute; display:inline-block; top:3px; left:48%; color: #7F98B2;}
</style>
@endsection
@section('content')
<div class="container">
<div class="row">
<div class=" col-md-12">
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">FILE</h3>
</div>
<div class="panel-body">
@include('partials.errors')
{!! Form::open(['route'=> 'attachment.store', 'method' => 'POST', 'files'=>'true']) !!}
<input type="hidden" name="_token" value="{{ csrf_token() }}">
{!! Form::hidden('user_id', $user->id) !!}
<div class="progress">
<div class="bar"></div >
<div class="percent">0%</div >
</div>
<div class="form-group">
<input name="poster" id="poster" type="file" class="form-control"><br/>
<input type="submit" value="Submit" class="btn btn-success">
</div>
{!!Form::close()!!}
</div>
</div>
</div>
</div>
</div>
@endsection
@section('scripts')
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script>
function validate(formData, jqForm, options) {
var form = jqForm[0];
// Validate Not Null file input
if (!form.poster.value) {
alert('File not found');
return false;
}
}
(function() {
var bar = $('.bar');
var percent = $('.percent');
var status = $('#status');
$('form').ajaxForm({
beforeSubmit: validate,
beforeSend: function() {
status.empty();
var percentVal = '0%';
var posterValue = $('input[name=poster]').fieldValue();
bar.width(percentVal)
percent.html(percentVal);
},
uploadProgress: function(event, position, total, percentComplete) {
var percentVal = percentComplete + '%';
bar.width(percentVal)
percent.html(percentVal);
},
success: function() {
var percentVal = 'Wait, Saving';
bar.width(percentVal)
percent.html(percentVal);
},
complete: function(xhr) {
status.html(xhr.responseText);
window.location.href = "/home";
}
});
})();
</script>
@endsection