-
Notifications
You must be signed in to change notification settings - Fork 0
/
HtmlPage3.html
189 lines (184 loc) · 8.66 KB
/
HtmlPage3.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
<!DOCTYPE HTML>
<html lang="en">
<head>
<!-- Force latest IE rendering engine or ChromeFrame if installed -->
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><![endif]-->
<meta charset="utf-8">
<title>GH File Upload</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/jquery.fileupload.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/EPSStyle.css">
</head>
<body>
<div class="container">
<table border="0" cellpadding="0" cellspacing="0" class=tablelook>
<tr class="FrameBG">
<td height="25" align="center" width="100%">Select File and Upload</td>
</tr>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td height="40" align="center" class="smallbold">
<table>
<tr>
<td><div id="files" class="files">Choose a file or drag it onto the screen.</div></td>
<!-- The fileinput-button span is used to style the file input field as button -->
<td>
<span class="btn btn-sm btn-gray fileinput-button">
<span>Browse</span>
<input id="fileupload" type="file" name="files[]">
</span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<div id="progress" class="progress">
<div class="progress-bar progress-bar-success"></div>
</div>
</td>
</tr>
<tr>
<td id="upload-button" align="center">
<INPUT class="btn btn-sm btn-gray" value="Close" TYPE="button" onClick="javascript:window.close();">
</td>
</tr>
<tr>
<td align="center">
<br />
<div class="panel panel-default">
<span class="text-danger" />
</div>
</td>
</tr>
<tr>
<td align="center">
<div class="img-preview">
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/vendor/jquery.ui.widget.js"></script>
<script src="js/load-image.all.min.js"></script>
<script src="js/canvas-to-blob.min.js"></script>
<script src="js/jquery.iframe-transport.js"></script>
<script src="js/jquery.fileupload.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.fileupload-process.js"></script>
<script src="js/jquery.fileupload-image.js"></script>
<script src="js/jquery.fileupload-audio.js"></script>
<script src="js/jquery.fileupload-video.js"></script>
<script src="js/jquery.fileupload-validate.js"></script>
<script>
//This function generates a unique name in the header so that there is no risk of duplicate files when chunking files with the same name.
generateFileUniqueIdentifier = function (data) {
var file = data.files[0];
var result = file.relativePath || file.webkitRelativePath || file.fileName || file.name;
return result.replace(/[^0-9a-zA-Z_-]/img, "") + "-" + file.size + "-" + $.now();
};
//This function adds the x-headers to the header response so the web api knows its a chunked file.
$(function () {
$('#fileupload')
.bind('fileuploadsubmit', function (e, data) {
data.headers = $.extend(data.headers,
{ "X-File-Identifier": generateFileUniqueIdentifier(data) });
data.headers = $.extend(data.headers,
{ "database": "GHDemo" });
data.headers = $.extend(data.headers,
{ "folder": "documents" });
});
});
//This function sends the json file data in 2mb chunks to the web api.
$(function () {
var url = 'upload/uploaddocument/'
uploadButton = $('<button/>')
.addClass('btn btn-sm btn-blue btn-upload')
.prop('disabled', true)
.text('Processing...')
.on('click', function () {
var $this = $(this),
data = $this.data();
$this
.off('click')
.text('Abort')
.on('click', function () {
$this.remove();
data.abort();
});
data.submit().always(function () {
$this.remove();
});
});
$('#fileupload').fileupload({
maxChunkSize: 2000000, // 2 MB
url: url,
dataType: 'json',
autoUpload: false,
maxFileSize: 100000000, // 100 MB
singleFileUploads: true,
previewMaxWidth: 100,
previewMaxHeight: 100,
previewCrop: true,
acceptFileTypes: /(\.|\/)(gif|jpe?g|png|doc|docx|pptx|csv|xlsx|log|msg|odt|pages|rtf|tex|txt|wpd|wps|dat|key|pps|ppt|sdf|tar|xml|mp3|bmp|xlr|xls|zip|pdf)$/i
}).on('fileuploadadd', function (e, data) {
$('.text-danger').text('');
$(".progress-bar-success").css("background-color", "white");
$.each(data.files, function (index, file) {
$('#files').text(file.name);
});
$('.btn-upload').remove();
$('canvas').remove();
data.context = $('<span/>').appendTo('#upload-button');
$.each(data.files, function (index, file) {
var node = $('<span/>');
if (!index) {
node
.append(uploadButton.clone(true).data(data));
}
node.appendTo(data.context);
});
}).on('fileuploadprocessalways', function (e, data) {
$(".progress-bar-success").css("background-color", "white");
$('.text-danger').text('');
var index = data.index,
file = data.files[index],
node = $('.img-preview');
if (file.preview) {
node
.prepend(file.preview);
}
if (file.error) {
node
.append($('<span class="text-danger"/>').text(file.error));
}
if (index + 1 === data.files.length) {
data.context.find('button')
.text('Upload')
.prop('disabled', !!data.files.error);
}
}).on('fileuploadprogressall', function (e, data) {
$(".progress-bar-success").css("background-color", "green");
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .progress-bar').css(
'width',
progress + '%'
);
}).on('fileuploadfail', function (e, data) {
$(".progress-bar-success").css("background-color","red");
$('.text-danger').text('File upload failed: ' + data.errorThrown + ". Please try again in a few minutes. If you are still experiencing this issue, please contact us.");
}).prop('disabled', !$.support.fileInput)
.parent().addClass($.support.fileInput ? undefined : 'disabled');
});
</script>
</body>
</html>