【问题标题】:Extjs - multi upload fileExtjs - 多上传文件
【发布时间】:2013-06-19 06:14:41
【问题描述】:

我很好地处理单次上传文件使用PHP。现在我正在处理 multi upload 文件。
我发现了一个问题 Why don't added records appear in grid? 也许这是我找到的最好的多上传文件。我的代码在这里 http://jsfiddle.net/VQQea/

                    var form = Ext.getCmp('form').getForm();
                    if(form.isValid()){ 
                        form.submit({
                             method: 'POST',
                             url: 'example.php',
                             success: function(fp, o) {
                             }
                        });
                    }else {
                        alert('fail'); 
                    }

但我不知道 php 文件如何。
谁能告诉我一个php文件来上传上面的多文件非常感谢:)。

编辑:
我下面的代码将上传最后一个文件(不是多个文件:()。我怎样才能上传多个文件谢谢。

<?php
    if(isset($_FILES['fileuploadfield-1017-inputEl'])) {
        $file_name = $_FILES['fileuploadfield-1017-inputEl']['name'];
        $file_tmp =$_FILES['fileuploadfield-1017-inputEl']['tmp_name'];

        move_uploaded_file($file_tmp,$file_name);

        echo "{success:true}";
    }else {
        echo "{failure:true}";  
    }
?>

【问题讨论】:

    标签: extjs file-upload upload extjs4.1


    【解决方案1】:
    Ext.define('Ext.ux.form.MultiFile', {
        extend: 'Ext.form.field.File',
        alias: 'widget.multifilefield',
    
        initComponent: function () {
            var me = this;
    
            me.on('render', function () {
                me.fileInputEl.set({ multiple: true });
            });
    
            me.callParent(arguments);
        },
    
        onFileChange: function (button, e, value) {
            this.duringFileSelect = true;
    
            var me = this,
                upload = me.fileInputEl.dom,
                files = upload.files,
                names = [];
    
            if (files) {
                for (var i = 0; i < files.length; i++)
                    names.push(files[i].name);
                value = names.join(', ');
            }
    
            Ext.form.field.File.superclass.setValue.call(this, value);
    
            delete this.duringFileSelect;
        }
    });
    

    ExtJS 4.2.2 多重上传的现场演示是here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-04
      • 2012-03-24
      相关资源
      最近更新 更多