我正在使用此上传插件:https://github.com/harrydeluxe/extjs-ux#extuxuploadbutton
我想改变“url”属性。请告诉我怎么可能?
我尝试过这样做,但它不起作用:
UploadObject.uploader.url = '/newUrl.php?ObjId=1';
Ext.Loader.setConfig({
enabled: true,
paths: {
'Ext.ux': 'http://extjs.cachefly.net/extjs-4.1.1-gpl/examples/ux/',
'Ext.ux.upload': '../../ux/upload'
}
});
Ext.require(['Ext.grid.*',
'Ext.data.*',
'Ext.util.*',
'Ext.state.*',
'Ext.ux.upload.Button',
'Ext.ux.upload.plugin.Window']);
Ext.onReady(function() {
UploadObject = Ext.create('Ext.ux.upload.Button', {
renderTo: Ext.getBody(),
text: 'Select files',
//singleFile: true,
plugins: [{
ptype: 'ux.upload.window',
title: 'Upload',
width: 320,
height: 350
}
],
uploader:
{
url: '/1/getimages.php?ObjectId=',
uploadpath: '/Root/files',
autoStart: false,
max_file_size: '2020mb',
//...
}
//...
});
答案 0 :(得分:1)
此UX使用plupload插件上传文件,遗憾的是,它没有为您提供替换上传网址的快捷方法。
首先,创建对上传按钮的引用,如果只有一个上传器,可以像这样创建:
var uploadButton = Ext.ComponentQuery.query('uploadbutton')[0];
对plupload插件的引用将在uploader.uploader
内,因此运行:
var uploadButton = Ext.ComponentQuery.query('uploadbutton')[0],
uploader = uploadButton.uploader.uploader;
uploader.settings.url = '/newUrl.php?ObjId=1';
如果您想保留代码,那很好,只需确保在创建var
之前添加UploadObject
。
var UploadObject = Ext.create('Ext.ux.upload.Button', {
renderTo: Ext.getBody(),
text: 'Select files',
//singleFile: true,
plugins: [{
ptype: 'ux.upload.window',
title: 'Upload',
width: 320,
height: 350
}],
uploader: {
url: '/1/getimages.php?ObjectId=',
uploadpath: '/Root/files',
autoStart: false,
max_file_size: '2020mb',
//...
}
//...
});
UploadObject.uploader.uploader.settings.url = '/newUrl.php?ObjId=1';