• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

[SOLVED] EXUPLOAD1 Includes Additional Data In IFS File

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [SOLVED] EXUPLOAD1 Includes Additional Data In IFS File

    I used the example code to include a file upload feature on an app. The functionality works as advertised, however, it includes additional data in the IFS file:

    Code:
    ------WebKitFormBoundaryB2j5hJg8vG5k2D6C                        
    Content-Disposition: form-data; name="sid"                      
                                                                    
    flarblegarble(<<<< SID value)
    ------WebKitFormBoundaryB2j5hJg8vG5k2D6C                        
    Content-Disposition: form-data; name="app"                      
                                                                    
    flarblegarlbe(<<<< APPID value)
    Is there a way to get rid of this naturally or do i have to read through the file until i hit the first "-----"? I'm also aware of how to use CPYFRMIMPF and ignore errors (but what if there are legitimate errors...).
    Last edited by rkanemeier; 03-13-2014, 10:56 AM.

  • #2
    Try checking that your file upload field is the last data element passed. The vvupload routine looks for the start of the file stream and reads to the end. If your parms are after the file upload field they can get included.

    Comment


    • #3
      Hey Richard.

      Thanks for your response. I quite literally used the code from the example, and it seems the front-end indeed does have the file upload field as the last field in the list of items:

      Code:
          var uploadFormPanel = Ext.create('Ext.form.Panel', {
              width: 500,
              frame: true,
              //title: 'File Upload Form',
              autoHeight: true,
              bodyStyle: 'padding: 10px 10px 0 10px;',
              labelWidth: 35,
          	labelAlign: 'right',
              defaults: {
                  anchor: '95%',
                  allowBlank: false,
                  msgTarget: 'under'
              },
      		// !important: sid, app and pgm must be inserted into form as hidden fields so that they get passed as variables on form submission
              items: [{
      			xtype: 'hidden',
      			id: 'sid',
                  name: 'sid',
      			value: sessionStorage.sid
      		}, {
      			xtype: 'hidden',
      			id: 'app',
                  name: 'app',
      			value: Ext.getUrlParam('app')
      		}, {
      			xtype: 'hidden',
      			id: 'pgm',
                  name: 'pgm',
      			value: 'exupload1' // !important: you must specify the name of your program to call to retrieve the file
      		}, {
      			// !important: this field definition defines the file selection field
      			// it must have an id of "file" and it must be specified last in the list of fields on the form
                  xtype: 'fileuploadfield',
                  id: 'file',
      			name:'file',
                  emptyText: 'Click Browse to select file',
                  fieldLabel: 'File',
      			buttonCfg: {
                  	text: 'Browse...',
      				iconCls: 'magnifier'
      			}
              }],
              buttons: [{
                  text: 'Upload',
      			iconCls: 'arrow_up',
                  handler: function(){
                      if(uploadFormPanel.getForm().isValid()){
      	                uploadFormPanel.getForm().submit({
      	                    url: 'vvupload.pgm',
      	                    waitMsg: 'Uploading file...',
      	                    success: function(fp, o){
                                  Ext.Msg.show({
                                  	title: 'Success',
                                  	msg: o.result.msg,
                                  	buttons: Ext.Msg.OK,
                                  	icon: Ext.MessageBox.INFO
                                  });
                                  uploadWindow.hide();
      	                    },
      						failure: function(fp, o) {
                                  Ext.Msg.show({
                                  	title: 'Failure',
                                  	msg: o.result.msg,
                                  	buttons: Ext.Msg.OK,
                                  	icon: Ext.MessageBox.ERROR
                                  });
                                  uploadWindow.hide();
      						}
      	                });
                      }
                  }
              },{
                  text: 'Clear',
      			iconCls: 'cancel',
                  handler: function(){
                      fp.getForm().reset();
                  }
              }]
          });

      Comment


      • #4
        Here is a copy/paste of the network tab when vvupload is called:

        Code:
        ------WebKitFormBoundaryo5kb6gRAp89wHXGK
        Content-Disposition: form-data; name="sid"
        
        E2B1AC7351A08F5D5642A3DD812A99C5D4746DC20784BD72F205F39BB2D7E823
        ------WebKitFormBoundaryo5kb6gRAp89wHXGK
        Content-Disposition: form-data; name="app"
        
        1044
        ------WebKitFormBoundaryo5kb6gRAp89wHXGK
        Content-Disposition: form-data; name="pgm"
        
        exupload1
        ------WebKitFormBoundaryo5kb6gRAp89wHXGK
        Content-Disposition: form-data; name="file"; filename="rkupload.csv"
        Content-Type: application/vnd.ms-excel
        
        
        ------WebKitFormBoundaryo5kb6gRAp89wHXGK
        Content-Disposition: form-data; name="sid"
        
        E2B1AC7351A08F5D5642A3DD812A99C5D4746DC20784BD72F205F39BB2D7E823
        ------WebKitFormBoundaryo5kb6gRAp89wHXGK
        Content-Disposition: form-data; name="app"
        
        1044
        ------WebKitFormBoundaryo5kb6gRAp89wHXGK--
        Interesing that the sid and app are listed twice.

        Comment


        • #5
          Fyi,

          I fixed a few problems with the code listed above. I was referring to object "fp" when it should have been uploadFormPanel. this did not resolve the problem.

          Oh! We are on Valence 3.1.20120326 (maybe we need an update?).
          Last edited by rkanemeier; 03-12-2014, 04:14 PM.

          Comment


          • #6
            Interesting. It looks like the portal is not recognizing the post as a file upload and including the sid and app parms even though on a file upload they are supposed to be supplied as part of the form. Try adding the isUpload: true property on your form submit as shown below. That should force the portal to recognize that it's a file upload and not include the parms.

            Code:
            uploadFormPanel.getForm().submit({
               url: 'vvupload.pgm',
               isUpload: true
            ...

            Comment


            • #7
              Added the code. The upload process is still embedding the "webkit boundaries"

              Comment


              • #8
                Try adding fileUpload: true as a config on your form panel:
                Code:
                    var uploadFormPanel = Ext.create('Ext.form.Panel', {
                         fileUpload: true,
                          ...
                    });

                Comment


                • #9
                  Thanks for your response Eric. That did not work either. I also tried fileUpload: true where Richard asked me to put isUpload and that did not work. I also removed isUpload.

                  Comment


                  • #10
                    I spoke with CNX support, and we found the issue. I had an override for Ext.Ajax.on('beforerequest',..) in my app that was overriding a Valence supplied Ext.Ajax.on('beforerequest..') in file /../vvresources/valence-extjs4.js. The Valence supplied override was checking for isUpload. When isUpload was true, it cleared the extraParams. It was the extraParams of sid and app that were being appended to the file upload. I simply copied the Valence supplied overrides to my custom override and the problem went away.

                    This is for Valence 3.1 btw.

                    Comment

                    Working...
                    X