test.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. <style>
  9. .upload-btn {
  10. width: 130px;
  11. height: 25px;
  12. overflow: hidden;
  13. position: relative;
  14. border: 3px solid #06c;
  15. border-radius: 5px;
  16. background: #0cf;
  17. }
  18. .upload-btn:hover {
  19. background: #09f;
  20. }
  21. .upload-btn__txt {
  22. z-index: 1;
  23. position: relative;
  24. color: #fff;
  25. font-size: 18px;
  26. font-family: "Helvetica Neue";
  27. line-height: 24px;
  28. text-align: center;
  29. text-shadow: 0 1px 1px #000;
  30. }
  31. .upload-btn input {
  32. top: -10px;
  33. right: -40px;
  34. z-index: 2;
  35. position: absolute;
  36. cursor: pointer;
  37. opacity: 0;
  38. filter: alpha(opacity=0);
  39. font-size: 50px;
  40. }
  41. </style>
  42. <script src="../dist/jQuery.js"></script>
  43. <script>
  44. window.onload=function(){
  45. document.documentElement.focus()
  46. }
  47. </script>
  48. <script>
  49. var FileAPI = {
  50. // @default: "./dist/"
  51. staticPath: './dist/',
  52. // @default: FileAPI.staticPath + "FileAPI.flash.swf"
  53. flashUrl: './dist/FileAPI.flash.swf',
  54. // @default: FileAPI.staticPath + "FileAPI.flash.image.swf"
  55. flashImageUrl: './dist/FileAPI.flash.image.swf'
  56. };
  57. </script>
  58. <script src="../dist/FileAPI.js"></script>
  59. </head>
  60. <body>
  61. <div>
  62. <div class="js-fileapi-wrapper upload-btn">
  63. <div class="upload-btn__txt">Choose files</div>
  64. <input id="choose" name="uploadfile" type="file" multiple />
  65. </div>
  66. </div>
  67. <script>
  68. $(function(){
  69. $('iframe').bind( 'load', function(){} )
  70. FileAPI.debug = true
  71. $.support.cors = true;
  72. var choose = document.getElementById('choose');
  73. FileAPI.event.on(choose, 'change', function (evt){
  74. var files = FileAPI.getFiles(evt);
  75. FileAPI.filterFiles(files, function (file, info){
  76. return true;
  77. },
  78. function (files, rejected){
  79. if( files.length ){
  80. FileAPI.upload({
  81. dataType: 'string',
  82. url: 'http://192.168.2.236/api/icss/lisExcelRes/lisExcelAnalysis',
  83. files: {
  84. // 'hospitalCode':'A001',
  85. 'uploadfile': files[0]
  86. },
  87. headers:{
  88. // 'Content-Type':'Content-Type: multipart/form-data;'
  89. // 'Content-Type':'application/json;charset=UTF-8'
  90. // 'Content-type': "text/plain"
  91. },
  92. progress: function (evt){
  93. console.log(files,1111)
  94. alert(7)
  95. },
  96. complete: function (err, xhr){
  97. alert(9999)
  98. if( !err ){
  99. var result = xhr.responseText;
  100. alert(JSON.parse(result).code == 0?'成功':'失败')
  101. }else{
  102. alert(9)
  103. }
  104. }
  105. });
  106. }
  107. });
  108. });
  109. })
  110. </script>
  111. </body>
  112. </html>