限时优惠活动
亲爱的苦力吧用户,我们为了回馈新老用户一直以来的鼎力支持,即日起(2025-02-06至2025-03-06)凡是购买苦力吧VIP/充值K币的新老用户,都直接可获得买一送一的优惠馈赠。例如:购买一个月的VIP会员可直接获得两个月的VIP会员;充值100K币可直接获得200K币,以此类推!有任何疑问可联系在线客服,感谢各位用户对苦力吧素材的信任与厚爱,我们将一如既往的给大家上新更多优质的素材源码,祝大家开工大吉、工作顺利、心想事成。

jquery鼠标拖拽多文件上传插件

所属分类: 网页特效-图片特效&上传    2023-08-24 10:57:51

jquery鼠标拖拽多文件上传插件 ie兼容6
 查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

jquery鼠标拖拽多文件上传插件(共5个文件)

    • index.html

使用方法

'use strict';

jQuery.fn.extend({

	bs_dropzone: function (options) {

		let $group, $element, $area, $box, $input, $preview, $line, $column, $image, defaults, files, flag, reader, extension;

		defaults = {
			preview: false,
			allowed: ['jpg', 'jpeg', 'png', 'bmp', 'webp', 'jfif', 'svg', 'ico', 'gif'],
			accepted: [],
			dropzoneTemplate: '<div class="bs-dropzone"><div class="bs-dropzone-area"></div><div class="bs-dropzone-message"></div><div class="bs-dropzone-preview"></div></div>',
			parentTemplate: '<div class="row"></div>',
			childTemplate: '<div class="col"></div>',
			boxClass: 'alert text-center',
			imageClass: 'img-fluid',
			noneColorClass: 'alert-info',
			dragColorClass: 'alert-warning',
			doneColorClass: 'alert-success',
			failColorClass: 'alert-danger',
			language: {
				emptyText: '[将文件拖到此处或单击上传]',
				dragText: '[将文件拖到此处]',
				dropText: '[_t_ File(s)]'
			},
			change: function () {}
		};

		options = $.extend({}, defaults, options);
		$group = this;

		$group.each(function (i) {

			$element = $(this);
			if ($element.attr('accept') == undefined && options.accepted.length > 0) {
				$element.attr('accept', '.' + options.accepted.join(', .'));
			}
			$element.after(options.dropzoneTemplate);
			$element.appendTo($element.next().find('.bs-dropzone-area'));
			$area = $('<div></div>');
			$area.attr('class', 'bs-dropzone-box ' + options.boxClass + ' ' + options.noneColorClass).text(options.language.emptyText);
			$element.before($area);

			$element.on('dragover', function () {

				$(this).prev().attr('class', 'bs-dropzone-box ' + options.boxClass + ' ' + options.dragColorClass).text(options.language.dragText);
			
			}).on('dragleave drop', function () {

				$input = $(this);
				files = this.files;
				$input.prev().attr('class', 'bs-dropzone-box ' + options.boxClass + ' ' + options.noneColorClass).text((files.length > 0) ? (options.language.dropText.replace(/_t_/g, files.length)) : options.language.emptyText);
				$input.trigger('blur');

			}).on('change', function () {

				$input = $(this);
				$input.trigger('preview');
				$input.trigger('blur');
				options.change.call(this, $input, this.files);

			}).on('preview', function () {

				$input = $(this);
				$box = $input.prev();
				$preview = $input.closest('.bs-dropzone').find('.bs-dropzone-preview');
				$preview.empty();
				files = this.files;
				flag = false;
				if (files.length > 0) {
					if (options.preview) {
						$line = $(options.parentTemplate);
						$.each(files, function (i) {
							extension = files[i].name.match(/\.[0-9a-z]+$/i);
							extension = (extension) ? extension[0].split('.').pop().toLowerCase() : null;
							if ($.inArray(extension, options.allowed) + 1 > 0) {
								reader = new FileReader();
								reader.onload = function (e) {
									$image = $('<img src="' + e.target.result + '" class="' + options.imageClass + '">');
									$column = $image.wrap(options.childTemplate).parent();
									$column.appendTo($line);
								}
								reader.readAsDataURL(this);
								flag = true;
							}
						});
						if (flag) {
							$line.appendTo($preview);
							$preview.show();
						}
					}
					$box.text(options.language.dropText.replace(/_t_/g, files.length));
				} else {
					$preview.hide();
					$box.text(options.language.emptyText);
				}

			}).on('clear', function () {

				$input = $(this);
				$box = $input.prev();
				$preview = $input.closest('.bs-dropzone').find('.bs-dropzone-preview');
				$box.attr('class', 'bs-dropzone-box ' + options.boxClass + ' ' + options.noneColorClass).text(options.language.emptyText);
				$preview.empty();
				$preview.hide();

			}).on('validation', function (event, state) {

				$input = $(this);
				$box = $input.prev();
				$preview = $input.closest('.bs-dropzone').find('.bs-dropzone-preview');
				if (state) {
					$box.attr('class', 'bs-dropzone-box ' + options.boxClass + ' ' + options.doneColorClass);
				} else {
					$box.attr('class', 'bs-dropzone-box ' + options.boxClass + ' ' + options.failColorClass);
					$preview.hide();
				}
				$input.css('height', $box.outerHeight());

			});

			$element.closest('form').on('reset', function () {

				$(this).find(':file').each(function () {

					$(this).trigger('clear');

				});

			});

		});

	}

});

站长提示:
1. 苦力吧素材官方QQ群:950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励2K币
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 图片特效&上传

jquery带悬浮缩略图的焦点图插件

一款大气的网站焦点图插件,将页面中的指定元素进行切换,比如文字和图片,背景固定。
  图片特效&上传
 3125  0

jquery轻量级文件上传预览插件

Tower是一个小而简单的文件上传插件,支持图片预览、自定义图标和文件列表。
  图片特效&上传
 5645  0

jquery带加载动画的图片弹出层左右切换插件

一款响应式图片放大镜插件,带上一张下一章左右切换按钮,动画加载特效。
  图片特效&上传
 7272  0

jquery仿淘宝主图上传支持拖拽

一款可拖拽上传图片的jq插件,带即时预览,很实用!
  图片特效&上传
 5326  0

评论数(1) 回复有机会获得K币 用户协议

    铁头de科技0
    2024-01-18 20:04:35
    多文件上传刚好能用上,感谢苦力吧
    回复
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论