Extjs在上传文件时无法第二次上传文件

时间:2014-07-10 08:00:20

标签: javascript extjs file-upload extjs4 extjs4.1

我有一个奇怪的extjs文件上传行为。

文件上传定义为:

 items: [{
                    xtype: 'filefield',
                    itemId: 'uploadandsign',
                    buttonText: NG.getLabel('browse'),
                    buttonOnly: true,
                    hideLabel: true,
                    width: 100
                }]

如果文件上传成功,我会在屏幕上显示成功的标签,并删除“X”按钮:

onOpenFileBrowserChange: function (filefield, newValue, oldValue, eOpts) {
            var me = this,             
            form = filefield.up('form').getForm(),
            infoBox = invoiceorigin.down('#fileuploadinfoplaceholder'),
            fileDescription,
            secondfilefield,
            customerFileName = newValue.replace(/^.*[\\\/]/, ''),
            draft = me.getDraft(),
            isSigned = true,
            files = draft.files();

        if (filefield.itemId === 'uploadandsign') {
            isSigned = false;
            secondfilefield = invoiceorigin.down('#uploadnosign');
            fileDescription = 'File system, Unsigned';
        }           
        secondfilefield.disable();

        if (form.isValid()) {
            form.submit({
                url: NG.getLatestApiPath('WebInvoice', 'UploadInvoiceFile'),
                waitMsg: NG.getLabel('webinvoiceInvoiceOriginUploadingFile'),
                success: function (fp, o) {
                    if (o.result.success) {

                        var file = o.result.file;

                        files.add({
                            fileName: file.fileName,
                            createDate: file.createDate,
                            isAttachment: false,
                            isSigned: isSigned,
                            fileOrigin: fileDescription,
                            customerFileName: customerFileName,
                            invoiceFileOrigin: 'Local'
                        });

                        filefield.disable();
                        infoBox.removeAll();
                        infoBox.add(Ext.create('NG.view.webinvoice.InformationBox', {
                            data: {
                                closable: true,
                                icon: true,
                                iconCls: 'n-pdf-icon',
                                content: '<div class="n-text-overflow" style="width:145px;">' + fileDescription + '<br/>' + customerFileName + '</div>'
                            }
                        }));
                    }
                    else {                            
                    }
                },
                failure: function (form, action) {
                }
            });
        }
        return false;
    },

然后,如果我从#infobox中删除文件,则reset()函数调用:

onRemoveFileClick: function (view) {
            var me = this,
            invoiceorigin = view.up('invoiceorigin'),
            uploadNoSignBtn = invoiceorigin.down('#uploadnosign'),
            uploadAndSignBtn = invoiceorigin.down('#uploadandsign'),
            infoBox = invoiceorigin.down('#fileuploadinfoplaceholder'),
            draft = me.getDraft(),
            files = draft.files(),
            pagemanager = view.up('webinvoicepagemanager'),
            invoiceFilePlace = files.findExact('isAttachment', false);

        me.deleteFileConfirmReject(
            NG.getLabel('webinvoiceInvoiceOriginDeleteInvoiceFileTitle'),
            NG.getLabel('webinvoiceInvoiceOriginDeleteInvoiceFileMsg'),
            function (buttonId, text, opt) {
                if (buttonId == 'yes') {
                    infoBox.removeAll();
                    if (invoiceFilePlace > -1) {
                        files.removeAt(invoiceFilePlace);
                    }

                    me.fillInvoiceOriginStep(pagemanager);

                    uploadNoSignBtn.reset();
                    uploadAndSignBtn.reset();
                    uploadNoSignBtn.enable();
                    uploadAndSignBtn.enable();
                }
            });
    }

在此操作之后,如果我将选择相同的文件....页面没有任何反应...页面上没有任何更改事件..但是如果我选择不同的文件,行为就可以了。 在ExtJS文档中说reset()函数必须清除以前的文件上传...但是它没有帮助。

是否有任何机构符合此类文件上传ExtJS行为并可以帮助解决此问题?

非常感谢。

1 个答案:

答案 0 :(得分:0)

我尝试和工作得非常好的是从表单中获取具有典型JS document.getElementsByName('[name you give]'); 的文件,并且它完美地上传了文件你执行的事情很重要。

希望它有所帮助。