我正在尝试在我的项目中使用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)
但是,这不是我想要的方式.
有关如何实现这一目标的任何想法?