Results 1 to 9 of 9

Thread: why php $_FILES is empty whe uploading form via api ??

  1. #1
    Sencha User
    Join Date
    Feb 2010
    Location
    Figueres (Spain)
    Posts
    370
    Answers
    15

    Default Answered: why php $_FILES is empty whe uploading form via api ??

    Extjs 4.1.1 RC2

    When i upload a file, i receive an empty $_FILES in PHP

    I have this form:
    Code:
                                    // Formulario para subir la foto
                                    xtype: 'form',
                                    name: 'formularioSubirFoto',
                                    title: '',
                                    bodyPadding: 5,
                                    border: false,
                                    anchor: '100%',
                                    api: {
                                        submit: Ext.esicontactosDirect.esicontactos_contactos.subirFotoContacto
                                    },
                                    items: [{                                
                                        xtype: 'filefield',
                                        name: 'fotocontacto',
                                        fieldLabel: gt.dgettext('esicontactos','Foto'),
                                        labelWidth: 50,
                                        msgTarget: 'side',
                                        allowBlank: true,
                                        anchor: '100%',
                                        buttonOnly: false,
                                        buttonText: gt.dgettext('esicontactos','Seleccione una imagen...')
                                    }]
    And this is the submit process in mvc controller
    Code:
                    formularioSubirFoto.getForm().submit({
                        params: {
                            cto_id: cto_id,
                            cto_guid: cto_guid
                        },
                        waitMsg: gt.dgettext('esicontactos','Subiendo foto al servidor ... '),
                        success: function(form, action) {
    console.log("success");                        
                        },
                        failure: function(form, action) {
    console.log("failure");                        
                        }
                    });
    This is the php code that receives the extdirec api call
    Code:
        /**
         * Subir la foto de un Contacto
         * Este metodo tiene que estar agregado en la funcion esValido del esicontactos_uploader
         * @remotable
         * @formHandler
        */
        public static function subirFotoContacto( $_parametros, $_archivos ) 
        {          
    
    var_dump($_parametros);
    var_dump("<br />");                
    var_dump($_archivos['fotocontacto']['tmp_name']);
    var_dump("<br />");                
    var_dump($_archivos);
    var_dump("<br />");                
    var_dump($_FILES);
    var_dump("<br />");                
    
    ...................
    This is the post view in firebug
    Code:
    Encabezados de respuestaver fuente
    
    
    Cache-Control no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    Connection close
    Content-Type text/html
    Date Tue, 04 Sep 2012 16:05:37 GMT
    Expires Thu, 19 Nov 1981 08:52:00 GMT
    Pragma no-cache
    Server Apache
    Transfer-Encoding chunked
    Encabezados de solicitudver fuente
    Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Encoding gzip, deflate
    Accept-Language es-es,es;q=0.8,en-us;q=0.5,en;q=0.3
    Connection keep-alive
    Cookie __utma=70484738.1139431865.1346054497.1346138584.1346417597.3; __utmz=70484738.1346054497.1.1.utmcsr=esigest.com|utmccn=(referral)|utmcmd=referral|utmcct=/; PHPSESSID=oj5enn5ti4uvsts1flfbi601o7
    Host www.cesilabs.com
    Referer https://www.cesilabs.com/esinube_desarrollo/aplicaciones/esicontactos/?desarrollo
    User-Agent Mozilla/5.0 (Windows NT 6.1; rv:14.0) Gecko/20100101 Firefox/14.0.1 FirePHP/0.7.1
    x-insight activate
    Encabezados de respuesta de datos enviados
    Content-Length 793
    Content-Type multipart/form-data; boundary=---------------------------64222494627506
    The response in php
    Code:
    array(7) {   ["cto_id"]=>   string(1) "1"   ["cto_guid"]=>   string(13) "4f67784c0ae0e"   ["extTID"]=>   string(2) "11"   ["extAction"]=>   string(22) "esicontactos_contactos"   ["extMethod"]=>   string(17) "subirFotoContacto"   ["extType"]=>   string(3) "rpc"   ["extUpload"]=>   string(4) "true" } string(6) "<br />" NULL string(6) "<br />" array(0) { } string(6) "<br />" array(0) { } string(6) "<br />" <html><body><textarea>{"type":"rpc","tid":"11","action":"esicontactos_contactos","method":"subirFotoContacto","result":{"success":true}}</textarea></body></html>

    Please help, i'm going crazy. :-((
    -------------------
    Manel Juarez

  2. Scott,

    I want to apologize for having wasted your time. Your suggestion to update to version 4.1.1 allowed me to see that the problem with the upload, it I had elsewhere in my code that destroyed the form in a previous save to submit the upload. Sorry, and thanks for your help.

    I can confirm that there is no bug with submit api upload and extjs 4.1.1
    It works fine.

  3. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    Specify the url in your submit and see if you get a value:

    $_FILES['file']['name']
    Code:
    form.getForm().submit({
        url: 'upload_file.php',
        waitMsg: 'Uploading ...',
        success: function(fp, o){
            me.close();
        }
    });
    Scott.

  4. #3
    Sencha User
    Join Date
    Feb 2010
    Location
    Figueres (Spain)
    Posts
    370
    Answers
    15

    Default

    Scott, i put this in index.php

    Code:
    var_dump("hello");
    var_dump($_FILES);
    var_dump($_FILES['fotocontacto']['name']);
    die;
    and have deleted in form the api config, and put url in submit
    Code:
                    formularioSubirFoto.getForm().submit({
                        url: 'index.php',
                        params: {
                            cto_id: cto_id,
                            cto_guid: cto_guid
                        },
                        waitMsg: gt.dgettext('esicontactos','Subiendo foto al servidor ... '),
                        success: function(form, action) {
    console.log("success");                        
                           //Ext.Msg.alert('Success', action.result.msg);
                        },
                        failure: function(form, action) {
    console.log("failure");                        
                        }
                    });
    The result is also empty $_FILES
    I'm sure that i'm selecting an small .txt file to upload (100Kb)

    Code:
    string(5) "hello" array(0) { } NULL
    -------------------
    Manel Juarez

  5. #4
    Sencha User
    Join Date
    Feb 2010
    Location
    Figueres (Spain)
    Posts
    370
    Answers
    15

    Default

    could it be a bug in extjs 4.1.1 rc2 ?
    Extdirect form post (file upload) doesn't send the content of uploaded file in post firebug analysis

    I've read a bug similar in this post...
    http://www.sencha.com/forum/showthre...e-4.1&p=882708
    -------------------
    Manel Juarez

  6. #5
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    Please upgrade and report back. 4.1.1 has been released and you should not be using rc2

    Scott.

  7. #6
    Sencha User
    Join Date
    Feb 2010
    Location
    Figueres (Spain)
    Posts
    370
    Answers
    15

    Default

    Quote Originally Posted by scottmartin View Post
    Please upgrade and report back. 4.1.1 has been released and you should not be using rc2

    Scott.

    Scott, i have upgraded to extjs 4.1.1 , and tested again.
    The same result.
    Analyzing post with firebug, it doesn't send any file.
    In php i found $_FILES as an empty array()
    -------------------
    Manel Juarez

  8. #7
    Sencha User
    Join Date
    Feb 2010
    Location
    Figueres (Spain)
    Posts
    370
    Answers
    15

    Default

    Scott, i think that probably the problem could be in another piece of code. I'm analysing it. Before to upload the file, i'm saving a model record. I try changing code structure and reporting back.
    -------------------
    Manel Juarez

  9. #8
    Sencha User
    Join Date
    Feb 2010
    Location
    Figueres (Spain)
    Posts
    370
    Answers
    15

    Default

    Scott,

    I want to apologize for having wasted your time. Your suggestion to update to version 4.1.1 allowed me to see that the problem with the upload, it I had elsewhere in my code that destroyed the form in a previous save to submit the upload. Sorry, and thanks for your help.

    I can confirm that there is no bug with submit api upload and extjs 4.1.1
    It works fine.
    -------------------
    Manel Juarez

  10. #9
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    Thank you for the update. All is well.

    Scott.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •