-
4 Sep 2012 8:17 AM #1
Answered: why php $_FILES is empty whe uploading form via api ??
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:
And this is the submit process in mvc controllerCode:// 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...') }]
This is the php code that receives the extdirec api callCode: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 post view in firebugCode:/** * 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 />"); ...................
The response in phpCode:Encabezados de respuestaver fuente
Encabezados de solicitudver fuenteCache-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 respuesta de datos enviadosAccept 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 Content-Length 793 Content-Type multipart/form-data; boundary=---------------------------64222494627506
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 Juàrez
-
Best Answer Posted by maneljn
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.
-
4 Sep 2012 9:19 AM #2Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,190
- Vote Rating
- 195
- Answers
- 436
Specify the url in your submit and see if you get a value:
$_FILES['file']['name']Scott.Code:form.getForm().submit({ url: 'upload_file.php', waitMsg: 'Uploading ...', success: function(fp, o){ me.close(); } });
-
4 Sep 2012 9:38 AM #3
Scott, i put this in index.php
and have deleted in form the api config, and put url in submitCode:var_dump("hello"); var_dump($_FILES); var_dump($_FILES['fotocontacto']['name']); die;
The result is also empty $_FILESCode: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"); } });
I'm sure that i'm selecting an small .txt file to upload (100Kb)
Code:string(5) "hello" array(0) { } NULL-------------------
Manel Juàrez
-
5 Sep 2012 7:41 AM #4
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 Juàrez
-
5 Sep 2012 10:56 AM #5Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,190
- Vote Rating
- 195
- Answers
- 436
Please upgrade and report back. 4.1.1 has been released and you should not be using rc2
Scott.
-
5 Sep 2012 11:47 PM #6
-
5 Sep 2012 11:57 PM #7
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 Juàrez
-
6 Sep 2012 1:08 AM #8
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 Juàrez
-
7 Sep 2012 9:44 AM #9Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,190
- Vote Rating
- 195
- Answers
- 436
Thank you for the update. All is well.
Scott.


Reply With Quote