upload_ajax구현못함.html
8.93 KB
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta name="description" content="1">
<meta name="keywords" content="1">
<meta name="author" content="1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Age Detection</title>
<link rel="stylesheet" href="http://211.249.50.30:8080/assets/css/bootstrap.min.css">
<link rel="stylesheet" href="http://211.249.50.30:8080/assets/css/animate.css">
<link rel="stylesheet" href="http://211.249.50.30:8080/assets/css/magnific-popup.css">
<link rel="stylesheet" href="http://211.249.50.30:8080/assets/css/font-awesome.min.css">
<!-- MAIN CSS -->
<link rel="stylesheet" href="http://211.249.50.30:8080/assets/css/tooplate-style.css">
</head>
<body>
<style type="text/css">
.buttonWrap {
position:relative;
float:left;
overflow:hidden;
cursor:pointer;
background-image:url('http://211.249.50.30:8080/example.jpg');
width:500px;
height:615px;
margin:0 auto;
}
.buttonWrap input {
position:absolute;
margin-left:-10px;
filter:alpha(opacity=0);
opacity:0;
-moz-opacity:0;
cursor:pointer;
width:74px;
height:20px;
margin:0 auto;
}
</style>
<!-- 이미지 미리보기 -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
function getThumbnailPrivew(html, $target) {
if (html.files && html.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$target.css('display', '');
//$target.css('background-image', 'url(\"' + e.target.result + '\")'); // 배경으로 지정시
$target.html('<img src="' + e.target.result + '" border="0" alt="" />');
}
reader.readAsDataURL(html.files[0]);
}
}
</script>
<style>
.filebox label {
display: inline-block;
padding: .5em .75em;
color: #999;
font-size: inherit;
line-height: normal;
vertical-align: middle;
background-color: #fdfdfd;
cursor: pointer;
border: 1px solid #ebebeb;
border-bottom-color: #e2e2e2;
border-radius: .25em;
width:100%;
max-width:100%;
}
.filebox input[type="file"] { /* 파일 필드 숨기기 */
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip:rect(0,0,0,0);
border: 0;
}
</style>
<!-- 나이 측정 API -->
<script type="text/javascript">
function test(){
var params = {
// Request parameters <img src="http://localhost:8080/user/mypic.jpg"></img>
"returnFaceId": "true",
"returnFaceLandmarks": "false",
"returnFaceAttributes": "age,gender",
};
$.ajax({
// NOTE: You must use the same location in your REST call as you used to obtain your subscription keys.
// For example, if you obtained your subscription keys from westus, replace "westcentralus" in the
// URL below with "westus".
url: "https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect?" + $.param(params),
beforeSend: function(xhrObj){
// Request headers
xhrObj.setRequestHeader("Content-Type","application/json");
// NOTE: Replace the "Ocp-Apim-Subscription-Key" value with a valid subscription key.
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","7482803a11e44146a53c4fb6a175d20f");
},
type: "POST",
// Request body.
data: '{"url":"http://211.249.50.30:8080/mypic.jpg"}',
})
.done(function(data) {
alert(JSON.stringify(data));
})
.fail(function(data) {
alert(JSON.stringify(data));
});
}
</script>
<!-- 파일 올리기 -->
<script>
$(document).ready(function() {
$('#uploadForm').submit(function() {
$("#status").empty().text("File is uploading...");
$(this).ajaxSubmit({
error: function(xhr) {
status('Error: ' + xhr.status);
},
success: function(response) {
$("#status").empty().text(response);
console.log(response);
}
});
//Very important line, it disable the page refresh.
return false;
});
});
</script>
<!-- PRE LOADER -->
<div class="preloader">
<div class="spinner">
<span class="spinner-rotate"></span>
</div>
</div>
<!-- HOME SECTION -->
<section id="home" class="parallax-section">
<div class="container">
<div class="row">
<div class="col-md-offset-5 col-md-7 col-sm-12">
<div class="home-thumb">
<h1 class="wow fadeInUp" data-wow-delay="0.4s">Age Dectection</h1>
<p class="wow fadeInUp white-color" data-wow-delay="0.6s">나이를 측정하러 오신 걸 환영합니다. <br/>당신은 사진을 업로드하여 사진에 있는 사람의 나이를 측정할 수 있습니다. <br/>
이 페이지는 Microsoft Face cognitive API를 사용하였으며 <br/>관심이 있으시면 <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/face/overview">Face API</a>링크를 참고하여 주십시오.</p>
<a href="#service" class="wow fadeInUp smoothScroll btn btn-default section-btn" data-wow-delay="1s">Let's Go</a>
</div>
</div>
</div>
</div>
</section>
<!-- SERVICE SECTION -->
<section id="service" class="parallax-section">
<div class="container">
<div class="row">
<div class="wow fadeInUp section-title" data-wow-delay="0.2s">
<!-- SECTION TITLE -->
<h2>자, 이제 나이를 측정하고 싶은 사람의 사진을 <br/>업로드 해주세요!</h2>
</div>
<form id="uploadForm" enctype="multipart/form-data"action="/uploads" method="post">
<input type="file" name="userPhoto" />
<input type="submit" value="Upload Image" name="submit">
<span id = "status"></span>
<button onclick="test()">click</button>
<img src="http://211.249.50.30:8080/mypic.jpg"></img>
</form>
<!--
업로드 생성
<form id="" enctype="multipart/form-data" action="/api/photo" method="post">
<input type="file" name="userPhoto" />
<input type="submit" value="Upload Image" name="submit">
<span id = "status"></span>
</form>
이미지 미리보기
<form name="form" id="form" action="" method="post" enctype="multipart/form-data" autocomplete="off">
<div class="filebox">
<label for="cma_file">사진 인증샷 업로드</label>
<input type="file" name="cma_file" id="cma_file" accept="image/*" capture="camera" onchange="getThumbnailPrivew(this,$('#cma_image'))" />
<br /><br />
<div id="cma_image" style="width:100%;max-width:100%;border:1px solid #000;display:none;"></div>
</div>
</form>
-->
</section>
<!-- FOOTER SECTION -->
<footer>
<div class="container">
<div class="row">
<div class="wow fadeInUp col-md-12 col-sm-12" data-wow-delay="0.8s">
<p class="white-color"> Opensource software programming 2017 Kang Jun Hu </p>
<div class="wow fadeInUp" data-wow-delay="1s">
<ul class="social-icon">
<li><a href="#" class="fa fa-facebook"></a></li>
<li><a href="#" class="fa fa-twitter"></a></li>
<li><a href="#" class="fa fa-instagram"></a></li>
<li><a href="#" class="fa fa-behance"></a></li>
<li><a href="#" class="fa fa-github"></a></li>
</ul>
</div>
</div>
</div>
</footer>
<!-- SCRIPTS -->
<script src="http://211.249.50.30:8080/assets/js/jquery.js"></script>
<script src="http://211.249.50.30:8080/assets/js/bootstrap.min.js"></script>
<script src="http://211.249.50.30:8080/assets/js/jquery.parallax.js"></script>
<script src="http://211.249.50.30:8080/assets/js/smoothscroll.js"></script>
<script src="http://211.249.50.30:8080/assets/js/jquery.magnific-popup.min.js"></script>
<script src="http://211.249.50.30:8080/assets/js/magnific-popup-options.js"></script>
<script src="http://211.249.50.30:8080/assets/js/wow.min.js"></script>
<script src="http://211.249.50.30:8080/assets/js/custom.js"></script>
</body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery.form/3.51/jquery.form.min.js"></script>
</html>