-
Notifications
You must be signed in to change notification settings - Fork 0
/
uploadimage.html
executable file
·250 lines (212 loc) · 10.7 KB
/
uploadimage.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
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<title>Lintel</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="font-awesome/css/font-awesome.min.css">
<script src="bootstrap/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<!-- remove this if you use Modernizr -->
<script>(function(e,t,n){var r=e.querySelectorAll("html")[0];r.className=r.className.replace(/(^|\s)no-js(\s|$)/,"$1js$2")})(document,window,0);</script>
<script type="text/javascript">
function reset_fun() {
document.getElementById('mylabel').innerHTML = "<strong>Drag files here<strong>";
document.getElementById('file').style.visibility = 'visible';
document.getElementById("myForm").reset();
}
function hidesubmit() {
document.getElementById('mysubmit').style.visibility = 'hidden';
document.getElementById("progress").style.visibility = 'visible';
}
function passworddiv() {
document.getElementById('Updatepassword').style.visibility = 'visible';
}
function passworddivhide() {
document.getElementById('Updatepassword').style.visibility = 'hidden';
}
</script>
<style>
.dropzone1 {
border:2px dotted #3498db;
padding: 20px;
width:100%;
height:40%;
color:#bdc3e7;
text-align: center;
}
.container-main {
margin-left:5%;
margin-right:5%;
margin-top : 5%;
}
.mybtn {
width: 70px;
}
body {
margin:0;
}
div.mydiv {
position: fixed;
z-index: 10;
padding : 0;
height : 400px;
background-color: #808080;
}
</style>
</head>
<body>
<br><br><br>
<div id="Updatepassword" class="container-fluid mydiv">
<span style="float:right; color:white; cursor:pointer" onclick="passworddivhide()";><strong>close ×</strong></span>
<iframe src="password.html" width="100%" height="100%" ></iframe>
</div>
<div class="well well-lg container-fluid container-main" id="maindivuploadimage">
<form id="myForm" method="post" action="insertimage.php" enctype="multipart/form-data" novalidate class="box">
<div class="dropzone1">
<label for="file" id="mylabel"><strong>Drag files here<strong></label>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-lg-8"><br><input type="file" name="files[]" id="file" class="box__file" data-multiple-caption="{count} files selected" multiple style="width:70%" /></div>
<div class="col-lg-*"></div>
</div>
<br>
<div class="row">
<div class="col-lg-2">UserName :</div>
<div class="col-lg-2"><input type="text" name="username" style="width:70%" required/></div>
<div class="col-lg-*"></div>
</div>
<br>
<div class="row">
<div class="col-lg-2">Password :</div>
<div class="col-lg-2"><input type="password" name="password" style="width:70%" required/></div>
<div class="col-lg-*"></div>
</div>
<br>
<div class="row">
<div class="col-lg-9"></div>
<div class="col-lg-3"><span id="progress" class="fa fa-spinner fa-pulse fa-2x" style="color:#2ead41"></span><button type="submit" id="mysubmit" class="btn btn-success mybtn" onclick="hidesubmit();" >Upload</button> <input type="reset" class="btn btn-failure mybtn" onclick="reset_fun();"/> <button type="button" class="btn btn-success" onclick="passworddiv();">Update Password</button></div>
</div>
</div>
</form>
</div>
<script type="text/javascript">
document.getElementById("Updatepassword").style.visibility = 'hidden';
document.getElementById("progress").style.visibility = 'hidden';
</script>
<script>
'use strict';
;( function ( document, window, index )
{
// applying the effect for every form
var forms = document.querySelectorAll( '.box' );
Array.prototype.forEach.call( forms, function( form )
{
var input = form.querySelector( 'input[type="file"]' ),
label = form.querySelector( 'label' ),
errorMsg = form.querySelector( '.box__error span' ),
restart = form.querySelectorAll( '.box__restart' ),
droppedFiles = false,
showFiles = function( files )
{
label.textContent = files.length > 1 ? ( input.getAttribute( 'data-multiple-caption' ) || '' ).replace( '{count}', files.length ) : files[ 0 ].name;
if ( files.length >= 1 ){
document.getElementById('file').style.visibility = 'hidden';
}
else {
document.getElementById('mylabel').innerHTML = "Drag files here";
document.getElementById('file').style.visibility = 'visible';
}
},
triggerFormSubmit = function()
{
var event = document.createEvent( 'HTMLEvents' );
event.initEvent( 'submit', true, false );
form.dispatchEvent( event );
};
// letting the server side to know we are going to make an Ajax request
var ajaxFlag = document.createElement( 'input' );
ajaxFlag.setAttribute( 'type', 'hidden' );
ajaxFlag.setAttribute( 'name', 'ajax' );
ajaxFlag.setAttribute( 'value', 1 );
form.appendChild( ajaxFlag );
// drag&drop files if the feature is available
[ 'drag', 'dragstart', 'dragend', 'dragover', 'dragenter', 'dragleave', 'drop' ].forEach( function( event )
{
form.addEventListener( event, function( e )
{
// preventing the unwanted behaviours
e.preventDefault();
e.stopPropagation();
});
});
form.addEventListener( 'drop', function( e )
{
droppedFiles = e.dataTransfer.files; // the files that were dropped
showFiles( droppedFiles );
});
// if the form was submitted
form.addEventListener( 'submit', function( e )
{
// preventing the duplicate submissions if the current one is in progress
if( form.classList.contains( 'is-uploading' ) ) return false;
form.classList.add( 'is-uploading' );
form.classList.remove( 'is-error' );
e.preventDefault();
// gathering the form data
var ajaxData = new FormData( form );
if( droppedFiles )
{
Array.prototype.forEach.call( droppedFiles, function( file )
{
ajaxData.append( input.getAttribute( 'name' ), file );
});
}
// ajax request
var ajax = new XMLHttpRequest();
ajax.open( form.getAttribute( 'method' ), form.getAttribute( 'action' ), true );
ajax.onload = function()
{
form.classList.remove( 'is-uploading' );
if( ajax.status >= 200 && ajax.status < 400 )
{
var data = JSON.parse( ajax.responseText );
if( !data[1].success ){
alert( data[1].message );
}
else {
alert( data[1].message );
window.location.assign("uploadimage.html");
}
}
else alert( 'Error. Please, contact the webmaster!' );
document.getElementById('mysubmit').style.visibility = 'visible';
document.getElementById("progress").style.visibility = 'hidden';
};
ajax.onerror = function()
{
alert( 'Error. Please, try again!' );
document.getElementById('mysubmit').style.visibility = 'visible';
};
ajax.send( ajaxData );
});
// restart the form if has a state of error/success
Array.prototype.forEach.call( restart, function( entry )
{
entry.addEventListener( 'click', function( e )
{
e.preventDefault();
input.click();
});
});
// Firefox focus bug fix for file input
input.addEventListener( 'focus', function(){ input.classList.add( 'has-focus' ); });
input.addEventListener( 'blur', function(){ input.classList.remove( 'has-focus' ); });
});
}( document, window, 0 ));
</script>
</body>
</html>