[CLOSED] File up load does not work and does not call Action result of relate upload a file

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] File up load does not work and does not call Action result of relate upload a file

    here my form from which i get the input fields
    <ext:Window runat="server" ID="window_Notes_File" Width="550px" Layout="Form" Title="Note Detail"
        Padding="10" AutoHeight="true" Modal="true" Closable="true" Resizable="false" >
        <Content>
    
    
            <ext:FormPanel ID="frm_Note_File" runat="server" FileUpload="true" Layout="FormLayout" Padding="5" Url="/Notes/UploadFile"
                RenderFormElement="true" BodyStyle="background-color:#dfe8f6" MonitorValid="true" BodyBorder="false" >
                <Content>
                    <ext:ComboBox Name="noteCategory" ID="cmb_Notes_File_NoteCategory" LabelPad="0" runat="server" FieldLabel="Note Category"
                        Editable="false" AnchorHorizontal="100%" DisplayField="Name" ValueField="Id"
                        EmptyText="Select a Catagory" AllowBlank="false">
                    </ext:ComboBox>
                    <ext:TextField Name="title" FieldLabel="Note Title" ID="txt_Notes_File_Title" runat="server"
                        AnchorHorizontal="100%" AllowBlank="false">
                    </ext:TextField>
                    <ext:FileUploadField ID="file" Name="file" runat="server" Icon="Attach" ButtonText="Brows"
                        FieldLabel="Upload File" AnchorHorizontal="100%" AllowBlank="false" />
                </Content>
                <Listeners>
                    <ClientValidation Handler="#{btn_Notes_File_Save}.setDisabled(!valid);" />
                </Listeners>
            </ext:FormPanel>
        </Content>
        <Buttons>
            <ext:Button ID="btn_Notes_File_Save" runat="server" Text="Save" Icon="Disk">
                <Listeners>
                <Click Handler="Note.saveFileNote()" />
                </Listeners>
            </ext:Button>
            <ext:Button ID="btn_Notes_File_Cancel" runat="server" Text="Cancel" Icon="Cross">
                <Listeners>
                    <Click Handler="#{window_Notes_File}.hide()" />
                </Listeners>
            </ext:Button>
        </Buttons>
    </ext:Window>
    form here request goes to java script

    saveFileNote: function () {
    
    
            var frmNote = Ext.getCmp(this.Note_File_Form);
            var params = { IAppTypeItem: this._AppTypeItem, IAppType: this._AppType };
            var url = '/Notes/UploadFile?' + Ext.urlEncode(params);
            Ext.encode(frmNote).getForm().submit({
            url: url,
            method: "POST",
            dataType: 'json',
            success: function () {
            Ext.net.Notification.show({
            iconCls: 'icon-information',
            pinEvent: 'mouseover',
            html: 'saved successfuly',
            title: 'Title'
            });
            Ext.getCmp(Note.Note_File_Window).hide();
            Note.reloadNotes();
            }
            });
        },
    reloadNotes: function () {
            if (this.getId() == 0) {
                var panel = Ext.getCmp(Note.getNotePanelID());
                GeneralHelper.updatePanel(panel, '/Notes/Index?IAppTypeItem=' + this.getAppTypeItem() + '&IAppType=' + this.getAppType());
                //Ext.getCmp(Request.Request_Detail_Panel_Notes).fireEvent('activate', Ext.getCmp(Request.Request_Detail_Panel_Notes));
            }
            else {
                Ext.getCmp(this.RequestGridId()).store.reload();
            }
        },
    and here is the action result to get upload file

     public void UploadFile(string title, string noteCategory, int IAppTypeItem, int IAppType)
            {   
                string Root = HttpContext.Server.MapPath("..\\NotesFiles");
    
    
                JsonResult result = new JsonResult();
                result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
                int? userId = HelpDeskWebApp.Models.User.getLoggedinUserId();
                if (userId != null)
                {
                    lock (NoteId)
                    {
                        //Uploaded File Contents
                        HttpPostedFileBase file = (HttpPostedFileBase)Request.Files["file"];                    
                        string fileName = file.FileName;
                        string fileExtention = Path.GetExtension(fileName);
    
    
                        //Directories
                        string dirSysTypePath = Root + "\\" + IAppType;
                        string dirSysTypeItemPath = dirSysTypePath + "\\" + IAppTypeItem;
    
    
                        //Creating Directories if not exist
                        DirectoryInfo dirInfoSysType = new DirectoryInfo(dirSysTypePath);
                        DirectoryInfo dirInfoSysTypeItem = new DirectoryInfo(dirSysTypeItemPath);
                        if (!dirInfoSysType.Exists)
                        {
                            dirInfoSysType.Create();
                        }
                        if (!dirInfoSysTypeItem.Exists)
                        {
                            dirInfoSysTypeItem.Create();
                        }
    
    
    
    
                        int noteId = (from note in db.Notes select note.NoteID).DefaultIfEmpty<int>(0).Max() + 1;
                        string filePath = dirSysTypeItemPath + "\\" + noteId.ToString()+"_"+fileName;
                        file.SaveAs(filePath);
                        int iNoteCategory = db.NoteCategories.First<NoteCategory>(nc => nc.Name == noteCategory).NoteCategoryID;
                        Note filenote = new Note()
                        {
                            Name = title,
                            NoteCategoryID = (short)iNoteCategory,
                            CreatedDateTime = DateTime.Now,
                            CreatedBy = (int)userId,
                            Detail = "",
                            AppTypeID = (byte)IAppType,
                            IAppTypeItem = IAppTypeItem,
                            FileUrl = filePath,
                            FileName = file.FileName,
                            NoteTypeID = (int)NoteTypeEnum.File
                        };
                        db.Notes.Add(filenote);
                        db.SaveChanges();
                    }
                    result.Data = "New Note Added Success Fully";
                }
                else
                {
                    result.Data = "Session Timed Out";
                }
            }
    please help me to get input fields from form into action method using ext.js
    thanks in advance
    Last edited by Daniil; Mar 19, 2013 at 4:23 AM. Reason: [CLOSED]

Similar Threads

  1. [CLOSED] multiple file upload and file size at client side
    By mirwais in forum 1.x Legacy Premium Help
    Replies: 24
    Last Post: Dec 15, 2014, 5:44 AM
  2. [CLOSED] Multiple file support to upload in file upload control
    By legaldiscovery in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 01, 2013, 9:41 AM
  3. Upload file with file path
    By yash.kapoor in forum 2.x Help
    Replies: 4
    Last Post: Nov 02, 2012, 11:15 AM
  4. Replies: 1
    Last Post: Jun 23, 2011, 9:37 AM
  5. [CLOSED] file upload - file name is empty
    By stoque in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 11, 2011, 8:06 PM

Posting Permissions