test.html 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>一次上传多张图片</title>
  6. <!-- 引入jQuery库 -->
  7. </head>
  8. <body>
  9. <h2>一次上传多张图片</h2>
  10. <form id="upload-form" enctype="multipart/form-data">
  11. <div class="form-group">
  12. <label for="images">选择多个图片:</label>
  13. <input type="file" name="images[]" id="images" multiple class="form-control">
  14. </div>
  15. <button type="button" id="upload-button" class="btn btn-primary">上传</button>
  16. </form>
  17. <div id="upload-status"></div>
  18. <script>
  19. $(document).ready(function () {
  20. $('#upload-button').click(function () {
  21. var formData = new FormData($('#upload-form')[0]);
  22. $.ajax({
  23. url: 'https://www.aa9169.com/Admin/Adminback/test_img', // 替换为你的服务器上传处理脚本的URL
  24. type: 'POST',
  25. data: formData,
  26. contentType: false,
  27. contentType: false,
  28. processData: false,
  29. success: function (response) {
  30. $('#upload-status').html(response);
  31. },
  32. error: function () {
  33. alert('上传失败,请重试!');
  34. }
  35. });
  36. });
  37. });
  38. </script>
  39. </body>
  40. </html>