1. #1
    Ext JS Premium Member
    Join Date
    Apr 2010
    Posts
    20
    Vote Rating
    0
    nikolawannabe is on a distinguished road

      0  

    Question File Upload with Ext.Direct

    File Upload with Ext.Direct


    Hello all!

    I'm fighting a losing battle with file uploads, as many have before from my searches while trying to find an answer for my problem. I'm using Ext JS library 3.0.3.

    I'm using Ext.Direct to call my api, and the code calling the api itself is a bit generic.

    The Short Story:
    Code:
    var isUpload = String(form.getAttribute("enctype")).toLowerCase() == 'multipart/form-data',
    in ext-all is complaining that form is not defined.

    My call stack looks like this:
    Code:
                                                    AddFunction: function(buttonList, tagName, frm) { 
    				    		debugger;
    				    		frm.getForm().submit();
    				    		DirectRequest.GetPostAttachments(buttonList.Post, function(res, resp) {
    				    			if ($KB.CheckValueResponse(resp)) {
    				    				var r = [];
    				    				for (var i = 0; i < res.Value.length; i++) {
    				    					var attachm = res.Value[i];
    				    					r[i] = { Text: attachm.FileName + '.' + attachm.FileExtn , Id: attachm.AttachmentId };
    				    				}
    				    			}
    				    		});
    						},
    Code:
            this.addTag = function(frm)
    	{
    		var tagName = Ext.getCmp(me.id+'tagName').getValue();
    		if(me.addFunction != null)
    		{
    			Ext.getCmp(me.id + 'addTagWindow').close();
    			me.addFunction(me, tagName, frm);
    		}
    	}
    Code:
                    var frmUpload = new Ext.FormPanel
    		(
    			{
    				id: 'uploadAttachment' + me.Post.toString(),
    				labelAlign:'top',
    				anchor:'0 0',
    				fileUpload: 'true',
    				standardSubmit: true,
    				monitorPoll: 500,
    				api: { submit: DirectRequest.AddPostAttachment },
    				bodyStyle:'background-color:transparent; padding:8px; ',
    				frame:false,hideBorders:true,border:false,
    				defaults:
    				{
    					labelSeparator:''
    				},
    				items:
    				[
    					{
    						xtype:'textfield',inputType: 'file',
    						headers: {'Content-type:':'multipart/form-data'},
    						fieldLabel:me.ButtonLabel,anchor:'100%',id:me.id+'fileUpload',
    						name: 'file',
    						buttonText: '',
    						enctype : 'multipart/form-data',
    						enableKeyEvents:true,
    						buttonCfg:
    						{
    							iconCls: 'upload-icon'
    						},
    						listeners:
    						{
    							keypress:function(tf,e)
    							{
    								if(e.keyCode == 13)
    								{
    									me.addTag(frmUpload);
    								}
    							}
    						}
    					},
    					{ xtype: 'hidden', id: 'attachForumPostId' + me.Post.toString(), value: me.Post }
    				],
    				buttons:
    				[
    					{
    						xtype:'button',
    						text:$KB.LZ('Wiki_Tag_Add', 'Add'),
    						handler:function()
    						{
    							me.addTag(frmUpload);
    						}
    					},
    					{
    						xtype:'button',
    						text:$KB.LZ('Cancel', 'Cancel'),
    						handler:function() {Ext.getCmp(me.id + 'addTagWindow').close();}
    					}
    				]
    			}
    I note that others have had a similar problem, but they seem to be doing a few things:
    • Getting the Latest version - Can't, we are not allowed to upgrade our version of ExtJS for this release as it causes too many side-effects that we would have to chase down and fix.
    • Overriding something - Not sure what an override file is, or if this is still relevant to me.
    • Giving up - Well, obviously not.

    If I've made a noob mistake somewhere; please be kind. I've been working with javascript in-depth for about a week.
    Last edited by nikolawannabe; 2 Jul 2010 at 3:59 PM. Reason: should use frm.getForm().submit() instead of frm.api.submit().

  2. #2
    Ext JS Premium Member
    Join Date
    Apr 2010
    Posts
    20
    Vote Rating
    0
    nikolawannabe is on a distinguished road

      0  

    Default


    Hi guys, I figured it out.

    I was closing the window which container the FormPanel before the form was sent. I added the window close to the add function in the success portion and it worked correctly.

Similar Threads

  1. [CLOSED][3.0RC1.1] Ext.Direct File Upload Fails
    By dancablam in forum Ext 3.x: Bugs
    Replies: 2
    Last Post: 1 Jun 2009, 9:10 AM
  2. File upload example for EXT 2.2
    By extjs_new in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 28 Dec 2008, 5:46 AM
  3. file upload file in an ext.window
    By anitsirc in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 10 Sep 2008, 1:12 PM
  4. How to use Ext to upload file?
    By uclali1986 in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 29 Mar 2008, 2:28 AM
  5. file upload in ext 2.0
    By aohza in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 15 Oct 2007, 8:00 PM
Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi