Results 1 to 3 of 3

Thread: File upload gives wrong file names. Characters encoding issue?

    You found a bug! We've classified it as a bug in our system. We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User
    Join Date
    Jul 2010
    Posts
    4

    Default File upload gives wrong file names. Characters encoding issue?

    Hello,

    I have a xtjs form that submits a file to the server. The header of my HTML file looks like this:

    <meta content="text/html;charset=UTF-8" http-equiv="content-type">

    In my form I have a texfield with the inputType: 'file' configuration (the full form code is bellow).

    When running the page, if I select a file with normal characters in its name (e.g. "hola.jpg") everything works OK and the file is transfered to the server. However, if I pick a file from my system with a name like this: "can.jpg" which contains utf-8 character in it, then the server receives wrong characters in the file name and it meses up my application.

    It seems to me that extjs is changing the charset to ASCII or something differently when submitting, but I don't know if it is a bug, or if I'm missing some configuration in my code.

    I'm using extjs 3.3.1

    full code bellow:

    Code:
    function ventanaNuevaFoto(){ 
    		Ext.QuickTips.init();
    		
    		var wnf = new Ext.Window({
          title: 'Aadir foto',
    			width: 350,
    			height: 140,
    			layout: 'fit',
    			modal: true,
          items: [{
            xtype: 'form',
    				fileUpload: true,
    				name: 'picture',
            id: 'fnf',
            url: '/obras/'+obra_id+'/crearfoto/'+mes_visualizado,
            frame: true,
            items: [
    				{
              xtype: 'textfield',
              fieldLabel: 'Foto',
              name: 'photo',
    					id: 'campoFoto',
    					width: 140,
    					allowBlank: false,
    					inputType: 'file'
              },{
              xtype: 'textfield',
              fieldLabel: 'Descripcin',
              name: 'descripcion',
    					id: 'campoDesc',
    					width: 140,
    					allowBlank: false
              }
    					,{
    					xtype: 'hidden',
              name: 'token_r',
    					value: token_r_var
    					}
            ]
          }],
          buttons: [{
            text: 'Cancelar',
            handler: function(){
              wnf.close(this);
              }
            },{
            text: 'Enviar',
            disabled: false,
              handler: function(){
              wnf.getComponent('fnf').getForm().doAction(
    						'submit',
    						{
    							success: function(f,a){
    								wnf.disable();
    								window.location = '/obras/'+obra_id+'/fotos/'+mes_visualizado;
    							},
    							failure: function(f,a){
    							if (a.failureType === Ext.form.Action.CLIENT_INVALID) {
                            Ext.Msg.alert('Error', 'Por favor rellene los dos campos correctamente');
                  }else{
    								resp = Ext.decode(a.response.responseText);
    								Ext.Msg.alert('Alerta', resp.msg);
    							}
    							},
    							waitMsg: 'Por favor espere',
    							waitTitle: 'Procesando'
    						}
              );
              }
            }
            ]
        });
        
        wnf.show();
      };

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    Specifying the Content-type as a meta tag doesn't make the HTML file UTF-8! Your server needs to specify the Content-type in the response header.

  3. #3
    Sencha User
    Join Date
    Jul 2010
    Posts
    4

    Default

    You are right. I was trying locally with my test server on my windows machine. Once I placed the application in the production server (apache @ linux) headers are being placed correctly and the problem is gone.

    Thanks for the hint.

Similar Threads

  1. How to disable file upload field and file upload icon
    By mypen in forum Ext 3.x: Help & Discussion
    Replies: 11
    Last Post: 18 Feb 2011, 7:45 AM
  2. How to disable file upload field and file upload icon
    By mypen in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 31 Jan 2011, 2:16 AM
  3. How to disable file upload field and file upload icon
    By mypen in forum Sencha Touch 1.x: Discussion
    Replies: 3
    Last Post: 26 Jan 2011, 1:04 AM
  4. [OPEN-708] BlackBerry WebWorks/PhoneGap issue: hyphens in file names
    By jkoutavas in forum Sencha Touch 1.x: Bugs
    Replies: 2
    Last Post: 7 Jan 2011, 7:06 AM
  5. Issue with File Upload
    By border9 in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 25 Jun 2009, 2:40 AM

Posting Permissions

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