You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
4.1 KiB

  1. <?php
  2. /*
  3. * The MIT License
  4. *
  5. * Copyright 2019 Blobt.
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8. * of this software and associated documentation files (the "Software"), to deal
  9. * in the Software without restriction, including without limitation the rights
  10. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. * copies of the Software, and to permit persons to whom the Software is
  12. * furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in
  15. * all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. * THE SOFTWARE.
  24. */
  25. ?>
  26. <header>
  27. <link href="http://hayageek.github.io/jQuery-Upload-File/4.0.11/uploadfile.css" rel="stylesheet">
  28. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  29. <script src="http://hayageek.github.io/jQuery-Upload-File/4.0.11/jquery.uploadfile.min.js"></script>
  30. </header>
  31. <body>
  32. <div id="showoldupload">
  33. <div class="ajax-upload-dragdrop" style="vertical-align: top; width: 600px;">
  34. <div class="ajax-file-upload" style="position: relative; overflow: hidden; cursor: default;">Upload
  35. <form method="POST" action="upload.php" enctype="multipart/form-data" style="margin: 0px; padding: 0px;">
  36. <input type="file" id="ajax-upload-id-1573635462220" name="myfile[]" accept="*" multiple=""
  37. style="position: absolute; cursor: pointer; top: 0px; width: 100%; height: 100%; left: 0px; z-index: 100; opacity: 0;">
  38. </form>
  39. </div>
  40. <span><b>Drag &amp; Drop Files</b></span></div>
  41. <div></div>
  42. </div>
  43. <div class="ajax-file-upload-container"></div>
  44. </body>
  45. <script>
  46. $("#showoldupload").uploadFile(
  47. {
  48. url: "upload",
  49. dragDrop: true,
  50. fileName: "file",
  51. returnType: "json",
  52. showDelete: true,
  53. showDownload: false,
  54. statusBarWidth: 300,
  55. dragdropWidth: 300,
  56. maxFileSize: 200 * 1024,
  57. dragDropStr: "<span><b>拖动上传</b></span>",
  58. sizeErrorStr: "图片超过最大尺寸限制",
  59. uploadErrorStr: "上传失败",
  60. showPreview: true,
  61. previewHeight: "60px",
  62. previewWidth: "60px",
  63. onSuccess: function (files, data) {
  64. $.ajax({
  65. url: "save-database",
  66. dataType: "json",
  67. data: {data: data, fileName: files},
  68. });
  69. },
  70. onLoad: function (obj) {
  71. $.ajax({
  72. cache: false,
  73. url: "previews",
  74. dataType: "json",
  75. success: function (data) {
  76. for (var i = 0; i < data.length; i++) {
  77. obj.createProgress(data[i]["name"], data[i]["path"], data[i]["size"]);
  78. }
  79. }
  80. });
  81. },
  82. deleteCallback: function (data, pd) {
  83. for (var i = 0; i < data.length; i++) {
  84. // alertify.confirm('系统提示', "确定执行批量 '"+act+"' 操作?", function() {
  85. $.post("image-del", {op: "delete", name: data[i]},
  86. function (resp, textStatus, jqXHR) {
  87. //Show Message
  88. alert("File Deleted");
  89. });
  90. // },function(){
  91. // });
  92. }
  93. pd.statusbar.hide(); //You choice.
  94. },
  95. });
  96. </script>