管道基础大数据平台系统开发-【CS】-ExportMap
1
13693261870
2022-11-16 66699d8e7f2ea458094ba06eb21166d735be94f2
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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>上传接口测试</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <script src="js/jquery.1.12.4.js"></script>
  <script>
    var url = "http://127.0.0.1:12316/";
    var token = "a5cca7ad-bfe6-43bd-aa62-e19f2ffac6bd";
 
    $(function () {
      $("#tokenSpan").html(token);
    });
 
    function ajax(url, type, data, dataType, contentType, fn) {
      $.ajax({
        url: url,
        type: type,
        data: data,
        dataType: dataType || "json", // html、json、jsonp、script、text
        contentType: contentType || "application/json", // "application/x-www-form-urlencoded"
        success: function (data) {
          fn(data);
        },
        error: function (e) {
          console.error(e);
          fn();
        }
      });
    }
 
    function getUrl(method) {
      return url + method + "?token=" + token;
    }
 
    function downloadMap(guid) {
      var a = document.createElement('a'); // 创建a标签
      a.style.display = 'none'; // 设置不可见
      a.href = getUrl("mark/downloadFile") + "&guid=" + guid;
 
      document.body.appendChild(a); // 加入
      a.click(); // 触发点击
      document.body.removeChild(a); // 释放
    }
 
    // 上传数据
    function uploadData() {
      var formData = new FormData();
      var fs = document.getElementById("file1");
      for (var i = 0, c = fs.files.length; i < c; i++) {
        formData.append(fs.files[i].name, fs.files[i]); // fs.files[i].name,file
      }
      formData.append("name", "测试");
      formData.append("dirid", "10");
      formData.append("depid", "1");
      formData.append("verid", "1");
      formData.append("type", "gdb");
      formData.append("cs", "CGCS 2000");
      formData.append("scale", "1:1000");
      formData.append("resolution", "0.5m");
      formData.append("gather", "2022-10-03 15:00:00");
      formData.append("descr", "");
 
      $.ajax(getUrl("uploader/uploadData"), {
        type: "post",
        data: formData,
        async: true,
        cache: false,
        processData: false,
        contentType: false,
        success: function (rs) {
          alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
          console.log(rs);
        },
        error: function (e) {
          console.error(e);
        }
      });
    }
 
    function uploadFiles() {
      var url = getUrl("uploader/");
    }
  </script>
</head>
<body>
  <form id="upForm" name="upForm" method="post" enctype="multipart/form-data" action="http://127.0.0.1:12316/file/upload">
    当前令牌:<span id="tokenSpan"></span><br />
 
    请选择文件:
    <input id="file1" name="file1" type="file" multiple="multiple" />
    <input id="btnUp" value="上传文件" type="button" onclick="uploadFiles();" />
  </form>
  <br />
  <br />
</body>
</html>