动态使用bleuimp上传jquery文件
Dynamically use bleuimp jquery file upload
我使用的是blueimp
JQuery fileupload
,但是我想动态地使用它。我有大约5个元素在我的网页上,他们每个人都应该调用javascript函数(自动上传)当一个文件被选中。下面是bleuimp
基本版的JQuery文件上传。我没有使用名为#fileupload
的div,而是使用id为#fileupload1
至#fileupload5
的5个div。
我想让javascript代码工作的所有5 #fileupload
id使用一个单一的javascript块。所以基本上我希望使用下面的代码,但所有5个元素。有办法做到这一点吗?如果有的话,有人能给我举个例子吗?谢谢你的帮助。
$(function () {
'use strict';
// Change this to the location of your server-side upload handler:
var url = window.location.hostname === 'blueimp.github.io' ?
'//jquery-file-upload.appspot.com/' : 'server/php/';
$('#fileupload').fileupload({
url: url,
dataType: 'json',
done: function (e, data) {
$.each(data.result.files, function (index, file) {
$('<p/>').text(file.name).appendTo('#files');
alert('DONE');
});
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .progress-bar').css(
'width',
progress + '%'
);
}
}).prop('disabled', !$.support.fileInput)
.parent().addClass($.support.fileInput ? undefined : 'disabled');
});
我找到了一个解决方案。也许不是最好的,但到目前为止,它适合我。
$('.dp-upload-container').each(function () {
// Code from $(function() { }); here using different ID's and classes dynamically.
});
相关文章:
- 为什么jQuery文件的函数中有两个参数,但只接收一个参数
- 限制文件类型,大小,单次上传不'无法在jquery文件上传中工作
- 在jquery文件上传中调用默认的done函数
- 使用send时,jquery文件上传不调整图像客户端的大小
- JQuery文件上载未检测到动态添加的输入
- php文件中包含的jquery文件在服务器上不起作用
- jQuery文件上传崩溃的浏览器
- Blueimp jQuery文件上传音频/视频限制
- 如何在 elfinder(一个 jquery 文件管理器插件)中只显示文件夹列表
- 如何在 Blueimp jquery 文件上传器中发送 I 会话数据
- 如何使用javascript动态添加基于现有文件的jquery文件
- 带有自定义进度条的 JQuery 文件上传 (blueimp)
- 如何将jQuery文件添加到导航网站
- Drupal 7 将 jQuery 文件添加到所有页面
- 将变量从 php 文件发送到 jquery 文件
- jQuery文件上传代码和回调
- jQuery文件上传和验证未定义函数
- 引导程序jquery文件上传和laravel
- 命令代码jquery文件错误
- jQuery文件上传库:如何点击单个文件进行上传