Art*_*hur 22 jquery jquery-plugins
我正在尝试在我的项目中使用blueimp jQuery文件上传.它很适合我的需求,但是我需要在创建和配置插件后动态上传url文件.我做了很多调查,但不幸的是,没有发现任何有用的东西.一般来说,我有一个按钮来选择文件和文件上传操作覆盖实际上传.基本创建如下:
$('[upload-button]').fileupload(new FileUploadConfig())
Run Code Online (Sandbox Code Playgroud)
并配置本身:
function FileUploadConfig() {
// is set to a unique value for each file upload
this.url = 'temporary';
this.fileInput = $('[upload-button]');
//... some other code
}
Run Code Online (Sandbox Code Playgroud)
我需要做的是更改此配置中的URL然后调用data.submit().我发现,这个配置是使用$.data()并试图解决这些代码的问题
// get the current fileupload configuration
var config = $.data($('[upload-button]').get(0), 'fileupload');
// change the url configuration option
config.options.url = file.link;
//send a file
data.submit();
Run Code Online (Sandbox Code Playgroud)
但是,这不是我想要的方式.
有关如何实现这一目标的任何想法?
Bil*_*ill 26
在这里捕捉这个为后代.
在当前的jQuery-upload rev中,覆盖add(evt,data)函数并设置数据对象的url属性:
fileupload({
add: function(e, data) {
data.url = 'customURL'
...
},
...
}
Run Code Online (Sandbox Code Playgroud)
autoupload当我想通过设置true并绑定回调将文件上传到具有不同 id 参数的 url 时,我已经完成了此操作fileuploadstart:
<script type='text/javascript'>
$(function () {
'use strict';
$('#fileupload').fileupload({
url: 'originalurl/dest/1'
autoUpload: true
}).bind('fileuploadadd', function (e, data) {
var that = $(this).data('fileupload');
that.options.url = 'originalurl/dest/' + $("#selctedlocation").val();
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
42540 次 |
| 最近记录: |