· 7 years ago · Nov 17, 2018, 02:48 AM
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="UTF-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1.0">
6 <meta http-equiv="X-UA-Compatible" content="ie=edge">
7 <title>Document</title>
8</head>
9<body>
10
11 <script>
12 function uploadFile() {
13 var blobFile = $('#filechooser')[0].files[0];
14 var formData = new FormData();
15
16 // upload image through form (jpg/jpeg/png)
17 formData.append("filename", blobFile);
18
19 // change the access_key and secret_key here
20 formData.append("access_key", "1ee882af28cbc7bb32bf");
21 formData.append("secret_key", "9afb6965bc11bb8cc60774a657b0c52df504bf15");
22
23 //To use Jquery, you can download it from http://jquery.com/download/
24 //or include it from a CDN into your HTML.
25 $.ajax({
26 url: "https://face.recoqnitics.com/analyze",
27 type: "POST",
28 data: formData,
29 processData: false,
30 contentType: false,
31 success: function(response) {
32 console.log(response);
33 $("#output").text(response.person.boundingBox.h)
34 },
35 error: function(jqXHR, textStatus, errorMessage) {
36 console.log(errorMessage); // Optional
37 }
38 });
39 }
40 </script>
41
42 <input id="filechooser" type="file"/>
43 <button onclick="uploadFile()">Upload!</button>
44 <p id="output"></p>
45 <script
46 src="https://code.jquery.com/jquery-3.3.1.js"
47 integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
48 crossorigin="anonymous"></script>
49
50
51</body>
52</html>