2017-03-23 2 views
0

ich bin mit ein paar Probleme mit der Multi-Datei hochladenExtJS 4.2 Filefield mehrere Upload

In meinem Controller erzeugen ich ein Fenster mit einem Formular und die Form hat einen Filefield und ein Raster:

var ventanaSubirDocumento=new Ext.Window({ 
     title: '<span style="color:#C85E00;">Subida de Documento</span>', 
     plain: true, 
     modal: true, 
     frame: true, 
     border: false, 
     resizable: false, 
     draggable: false, 
     scope:this, 
     items:[ 
       { 
        xtype:'form', 
        width: 400, 
        bodyPadding: 10, 
        frame: true, 
        timeout:600000,//Por si pesa mucho el archivo 
        renderTo: Ext.getBody(), 
        items: [{ 
         xtype: 'filefield', 
         name: '', 
         fieldLabel: '', 
         fieldStyle:'color:black', 
         labelWidth: '', 
         msgTarget: 'side', 
         allowBlank: false, 
         anchor: '100%', 
         buttonText: 'Seleccionar documento', 
         listeners: { 
          change: function(fld, value) { 
           //var newValue = value.replace(/C:\\fakepath\\/g, ''); 
           //fld.setRawValue(newValue); 
           var upload = fld.fileInputEl.dom; 
           var files = upload.files; 
           var names = []; 
           var names2 = []; 

           if (files) { 
            for (var i = 0; i < files.length; i++){ 
             names.push(files[i].name); 
             names2.push({archivo:files[i].name}) 
             value = names.join(', '); 
            } 
           } 
           gridDocumentos.getStore().loadData(names2); 
           fld.setRawValue(value); 
          }, 
          /*render:function(field, eOpts){ 
           field.fileInputEl.set({ multiple: true }); 
          }*/ 
          afterrender:function(cmp){ 
           cmp.fileInputEl.set({ 
            multiple:'multiple' 
           }); 
          } 
         } 
        }, 
        gridDocumentos 
        ], 
        buttons: [{ 
         text: 'Subir documento', 
         handler: function() { 
          var form = this.up('form').getForm(); 
          if(form.isValid()){ 
           form.submit({ 
            url: 'data/php/Tmc_SubirDocumento.php', 
            waitMsg: 'Subiendo documento...', 
            success: function(fp, o) { 
            ventanaSubirDocumento.close(); 
             Ext.Msg.show({ 
              title: 'Subida de documento', 
              msg: 'Documento subido', 
              icon: Ext.MessageBox.INFO, 
              buttons: Ext.Msg.OK 
             }); 
            } 
          } 
         } 
        }] 
     ] 
    }).show(); 

Im Controller funktioniert alles einwandfrei, wenn ich 1,2,3, etc ... Dateien auswähle, lädt sich das Raster mit seinen Namen auf.

Das Problem kommt, wenn ich das Formular abschicke und ein PHP für die Arbeit mit den ausgewählten Dateien ausführen, im PHP, wenn ich die $ _FILES-Variable drucke, bekomme ich nur die letzte ausgewählt.

In meinem PHP in der Anfrage Nutzlast Ich sehe die drei Dateien, aber nur $ _FILES hat die letzten:

------ WebKitFormBoundaryJhIv2MXqKkzPnNys Content-Disposition: form-data; name = "filefield-1459-inputEl"; filename = "DATEI1.DOC" Content-Type: application/msword

------ WebKitFormBoundaryJhIv2MXqKkzPnNys Content-Disposition: form-data; name = "filefield-1459-inputEl"; filename = "file2.docx" Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document

------ WebKitFormBoundaryJhIv2MXqKkzPnNys Content-Disposition: form-data; name = "filefield-1459-inputEl"; filename = "file3.docx" Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document

Fehle ich etwas Wie kann ich alle Dateien nach formsubmit in der PHP-Datei abrufen?

Antwort

2

Sie können Ihr Dateifeld benennen, sodass das name-Attribut der zugrunde liegenden HTML-Eingabe hinzugefügt wird.

... 
xtype: 'filefield', 
name: 'uploads[]', 
fieldLabel: '', 
... 

Dann können Sie sie auf PHP mit bekommen;

$_FILES["uploads"]; 
+0

Vielen Dank, jetzt kann ich auf alle Dateien in meinem php zugreifen. – SensacionRC

Verwandte Themen