[CLOSED] FileUploadField issue

  1. #1

    [CLOSED] FileUploadField issue



    Hello,

    I'm trying to upload files into the DB by using the FileUploadFiled control. The problem is than when I try to read a file of about 160 mb I get "Error during ajax event" comming from the AjaxEvent button. I have included the full code bellow. I think it happens in the Readfile() of the serverside method.


    HTML
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ProjectReferenceEdit.ascx.cs"
        Inherits="WebClientTrackerII.App.Projects.References.ProjectReferenceEdit" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    
    <script type="text/javascript">
        var ProjectReferencesRecord;
        
        var openProjectReferencesDetails = function (record, animTrg) {
        
            ProjectReferencesRecord = record;
            var window = <%= ProjectReferenceEditwindow.ClientID %>;
            window.setTitle(String.format('Project Reference: {0}',record.data['PRJCT_REFERNC_SUBJ_TXT']));
            
            <%= recvdDate.ClientID %>.setValue(record.data['PRJCT_REFERNC_RECVD_DT']);
            <%= TypeCmbx.ClientID %>.setValue(record.data['PRJCT_REFERNC_REFERNC_TYPE_ID']);
            <%= subjecttxt.ClientID %>.setValue(record.data['PRJCT_REFERNC_SUBJ_TXT']);
            <%= contentTxtArea.ClientID %>.setValue(record.data['PRJCT_REFERNC_TXT']);
            <%= fileNameTxt.ClientID %>.setValue(record.data['PRJCT_REFERNC_DOCMT_NM']);
            <%= RecordKeyID.ClientID %>.setValue(record.data['PRJCT_REFERNC_ID']);
            <%= SpeakerID.ClientID %>.setValue(record.data['PRJCT_REFERNC_PRJCT_SPKR_ID']);
            
                    
            window.show('');
        }
        
           var openReferencesDetailsNew = function(record) {
            
    
    
            var currentTime = new Date()
                
            ProjectReferencesRecord = record;
            var window = <%= ProjectReferenceEditwindow.ClientID %>;
            window.setTitle('New Project Reference');
            
            <%= recvdDate.ClientID %>.setValue(currentTime);
            <%= TypeCmbx.ClientID %>.setValue('');
            <%= subjecttxt.ClientID %>.setValue('');
            <%= contentTxtArea.ClientID %>.setValue('');
            <%= fileNameTxt.ClientID %>.setValue('');
            <%= RecordKeyID.ClientID %>.setValue('');
    
    
            window.show();
            
        }    
        
            
    </script>
    
    
    <asp:SqlDataSource ID="SqlDataSourceRefernceType" runat="server" ConnectionString="<%$ connectionStrings:DBConnectionString %>"
        ProviderName="<%$ connectionStrings:DBConnectionString.ProviderName %>" SelectCommand="SELECT REFERNC_TYPE_ID,
                        REFERNC_TYPE_NM,
                        REFERNC_TYPE_ACTV_IND
                    FROM TRACKER2.REFERNC_TYPE"></asp:SqlDataSource>
    <ext:Store ID="storeReferences" runat="server" DataSourceID="SqlDataSourceRefernceType">
        <Reader>
            <ext:JsonReader ReaderID="REFERNC_TYPE_ID">
                <Fields>
                    <ext:RecordField Name="REFERNC_TYPE_ID" />
                    <ext:RecordField Name="REFERNC_TYPE_NM" />
                    <ext:RecordField Name="REFERNC_TYPE_ACTV_IND" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    
    
    <ext:Hidden ID="RecordKeyID" runat="server" />
    <ext:Hidden ID="SpeakerID" runat="server" />
    
    
    <ext:Window ID="ProjectReferenceEditWindow" runat="server" Width="600" Height="280"
        AutoShow="false" Modal="true" Show&#111;nload="false" Resizable="false" BodyStyle="padding:5px; background-color:#F6F3EC">
        <Body>
            <ext:ColumnLayout ID="ColumnLayout1" runat="server">
                <ext:LayoutColumn ColumnWidth=".5">
                    <ext:Panel ID="Panel1" runat="server" Border="false" Header="false" Frame="false"
                        BodyStyle="background-color:#F6F3EC">
                        <Body>
                            <ext:FormLayout ID="FormLayout1" runat="server" LabelAlign="Left" LabelWidth="10">
                                <Anchors>
                                    <ext:Anchor>
                                        <ext:DateField ID="recvdDate" runat="server" FieldLabel="Date" Width="120">
                                        </ext:DateField>
                                    </ext:Anchor>
    
    
                                    <ext:Anchor>
                                        <ext:TextField ID="subjecttxt" runat="server" FieldLabel="Subject" Width="200">
                                        </ext:TextField>
                                    </ext:Anchor>
                                    
                                    <ext:Anchor>
                                        <ext:TextArea ID="contentTxtArea" runat="server" FieldLabel="Content" Width="180"
                                            Height="120">
                                        </ext:TextArea>
                                    </ext:Anchor>
                                </Anchors>
                            </ext:FormLayout>
                        </Body>
                    </ext:Panel>
                </ext:LayoutColumn>
                <ext:LayoutColumn ColumnWidth=".5">
                    <ext:Panel ID="Panel2" runat="server" Frame="false" Border="false" BodyStyle="background-color:#F6F3EC">
                        <Body>
                            <ext:FormLayout ID="FormLayout2" runat="server" LabelAlign="Left" LabelWidth="40">
                                <Anchors>
                                    <ext:Anchor>
                                        <ext:ComboBox ID="TypeCmbx" runat="server" StoreID="storeReferences" DisplayField="REFERNC_TYPE_NM"
                                            ValueField="REFERNC_TYPE_ID" TriggerAction="All" Mode="Local" Select&#111;nfocus="true"
                                            Editable="false" FieldLabel="Type">
                                        </ext:ComboBox>
                                    </ext:Anchor>
    
    
                                    <ext:Anchor>
                                        <ext:FileUploadField ID="FileUploadField1" runat="server" EmptyText="Select a File"
                                            FieldLabel="" HideLabel="true" ButtonText="" Icon="ImageAdd" Width="250">
                                        </ext:FileUploadField>
                                    </ext:Anchor>
                                    
                                    <ext:Anchor>
                                        <ext:TextField ID="fileNameTxt" runat="server" FieldLabel="File Name" Width="200">
                                        </ext:TextField>
                                    </ext:Anchor>
                                    
                                    <ext:Anchor>
                                        <ext:Button ID="viewFile" runat="server" Text="View File"></ext:Button>
                                    </ext:Anchor>
                                </Anchors>
                            </ext:FormLayout>
                        </Body>
                    </ext:Panel>
                </ext:LayoutColumn>
            </ext:ColumnLayout>
        </Body>
        <BottomBar>
            <ext:Toolbar ID="btmToolbar1" runat="server">
                <Items>
                    <ext:ToolbarButton ID="tlbrbtn1" runat="server" Text="View Reference" StandOut="true">
                    </ext:ToolbarButton>
                    <ext:ToolbarFill ID="toolbarFill1" runat="server">
                    </ext:ToolbarFill>
                    <ext:ToolbarButton ID="saveToolbarBtn" runat="server" Text="Save" Icon="Disk" StandOut="true">
                       <AjaxEvents>
                            <Click OnEvent="SaveReference" Failure="Ext.MessageBox.alert('Saving failed', 'Error during ajax event');">
                                <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="={#{ProjectReferenceEditWindow}.body}" />
                                <ExtraParams>
                                    <ext:Parameter Name="id" Value="#{RecordKeyID}.getValue()" Mode="Raw" />
                                </ExtraParams>
                            </Click>
                        </AjaxEvents>
                    </ext:ToolbarButton>
                    <ext:ToolbarButton ID="cancelToolbarBtn" runat="server" Text="Cancel" Icon="Cancel" StandOut="true">
                        <Listeners>
                            <Click Handler="#{ProjectReferenceEditWindow}.hide(null);" />
                        </Listeners>
                    </ext:ToolbarButton>
                </Items>
            </ext:Toolbar>
        </BottomBar>
    </ext:Window>
    Code behind
    
          public byte[] ReadFile()
            {
                byte[] file = null;
    
    
                if (this.FileUploadField1.HasFile &amp;&amp; this.FileUploadField1.PostedFile.ContentLength > 0)
                {
                    byte[] binary = new byte[FileUploadField1.PostedFile.ContentLength];
                    binary = FileUploadField1.FileBytes;
                    string filenametest = System.IO.Path.GetFileName(this.FileUploadField1.FileName);
                    this.fileNameTxt.Text = filenametest ;
                    file = binary;
                }
    
    
                return file;
            }
    
    
    
            /// <summary>
            /// Save reference
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            public void SaveReference(object sender, AjaxEventArgs e)
            {
    
    
                ReferencesBO refBO = new ReferencesBO();
                DataAccessLayer.Projects.ProjectsDAL projectDAL = new DataAccessLayer.Projects.ProjectsDAL();
    
    
                byte [] fileInBytes = this.ReadFile();
                DateTime? dtRecvd = (Nullable<DateTime>)this.recvdDate.Value;
                string referenceType = TypeCmbx.SelectedItem.Value;
                string subjectText = this.subjecttxt.Text.Trim();
                string documentName = this.fileNameTxt.Text.Trim();
                string contextText = this.contentTxtArea.Text;
                string speakerid = projectDAL.GetSpeakerFromGrant(Session["ProjectIDSess"].ToString());
    
    
    
                if (Validate(referenceType, dtRecvd, subjectText, fileInBytes, contextText))
                {
    
    
    
                    refBO.insertProjectReference(referenceType, dtRecvd, subjectText, documentName, contextText, fileInBytes, Session["UserNetworkName"].ToString(), speakerid);
    
    
    
                    //if (this.RecordKeyID.Value.ToString().Length > 0)
                    //{
                    //    refBO.updateProjectReference(this.RecordKeyID.Value.ToString(),referenceType, dtRecvd, subjectText, documentName, contextText, fileInBytes, Session["UserNetworkName"].ToString(), speakerid);
                    //}
                    //else
                    //{
                    //    refBO.insertProjectReference(referenceType, dtRecvd, subjectText, documentName, contextText, fileInBytes, Session["UserNetworkName"].ToString(), speakerid);
                    //}
                    
                }
    
    
            }
    Any help will be appreciated,
  2. #2

    RE: [CLOSED] FileUploadField issue

    Hi,

    Can you display response.responseText instead 'Error during ajax event'?


    What a text the response contains?
  3. #3

    RE: [CLOSED] FileUploadField issue

    Vlad,

    I get NORESPONSE message back when it's a big file. It work with smaller files.
  4. #4

    RE: [CLOSED] FileUploadField issue

    Hi,


    Try to increase the Timeout for AjaxEvent


    Timeout="300000"

    300000 ms - 5 min


    Does that big upload works with ASP.NET file upload control and postback? Did you increase maximum allowed size for iploading files?


    Try to play with the following settings in web.config


    <httpRuntime executionTimeout="90"  maxRequestLength="4096" />

    By default, ASP.NET permits only files that are 4,096 kilobytes (KB) (or 4 megabytes [MB]) or less to be uploaded to the Web server
  5. #5

    RE: [CLOSED] FileUploadField issue



    Vlad,


    I have tried a document (Word document) with 3.99 mb using the coolite samples online and I do not get an Ajax error. If the document is 4 mb the upload returns the ajax error. I think you should try it yourself.
    Does this control has a size limitation?


    Thank you,
  6. #6

    RE: [CLOSED] FileUploadField issue

    Hi egodoy,

    No, the control does not have a size limitation.


    Can you confirm you have implemented the suggested posted by Vladimir above? ASP.NET runtime has a 4 meg limit by default, so it's likely the 4 meg limit you are running into is the same thing.


    Geoffrey McGill
    Founder
  7. #7

    RE: [CLOSED] FileUploadField issue

    Yes I have implemeted it and did not work. Like I said before, I have tried the FileUpload sample on line and it works with a 3.99 mb file but not with a 4 mb or a bigger file.
  8. #8

    RE: [CLOSED] FileUploadField issue

    Hi,

    If increase 'maxRequestLength' in web.config then files with 4mb or bigger are uploading fine.
    Do you get error message immediately or after some time?
    Try to increase 'executionTimeout' if upload process is too long.
    If you change Coolite control by ASP.NET FileUpload does it work?


  9. #9

    RE: [CLOSED] FileUploadField issue

    It worked by increasing the 'maxRequestLength'

    Thank you,

Similar Threads

  1. [CLOSED] FileUploadField browse button issue
    By Daly_AF in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 28, 2012, 4:44 PM
  2. Replies: 4
    Last Post: Apr 24, 2012, 11:59 AM
  3. [CLOSED] FileUploadField issue
    By thaianhduc in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jan 19, 2011, 9:06 AM
  4. [CLOSED] [1.0] FileUploadField timeout issue
    By ljankowski in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 27, 2010, 5:04 PM
  5. [CLOSED] FileUploadField issue...
    By shahidmughal in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 29, 2010, 3:07 PM

Posting Permissions