[CLOSED] FileUploadField PostedFile always null

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] FileUploadField PostedFile always null

    Hey,

    I know this is a much-discussed problem, but I haven't found a solution that works yet.

    No matter which file I select, the FileUploadField1 is always empty in the handler.

    I have a page set up as follows (basically an example I found in another thread):

    <%@ Page 
        Language="C#"
        AutoEventWireup="True"
        CodeBehind="~/Views/Sales/PurchaseInvoiceImport.aspx.cs"
        Inherits="eAccounts.Web.Views.Sales.PurchaseInvoiceImport"
        MasterPageFile="~/Views/Shared/DesktopMasterPage.Master" %>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
        <script runat="server">
            protected void FileUploadField_FileSelected(object sender, DirectEventArgs e)
            {
                this.FileUploadField1.PostedFile.SaveAs("C:\\Documents\\TESTFILE.txt");
            }
        </script>
    </asp:Content>
    
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
        <form id="form1" runat="server">
            <ext:ResourceManager ID="ResourceManagerPurchaseInvoiceImport" runat="server"/>
            <ext:FileUploadField ID="FileUploadField1" runat="server" Width="300">
                <DirectEvents>
                    <FileSelected OnEvent="FileUploadField_FileSelected" IsUpload="true" />
                </DirectEvents>
            </ext:FileUploadField>
        </form>
    </asp:Content>
    Any help would be greatly appreciated.
    Last edited by Daniil; Oct 04, 2013 at 5:39 AM. Reason: [CLOSED]
  2. #2
    Hi @neat,

    Welcome to the Ext.NET forums!

    Please demonstrate the Master Page.
  3. #3
    Master page:

    <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="DesktopMasterPage.master.cs"
        Inherits="eAccounts.Web.Views.Shared.DesktopMasterPage" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head id="MainHead" runat="server">
        <title>
            <asp:ContentPlaceHolder ID="TitleContent" runat="server" />
        </title>
    
        <ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" />
    
        <link href="/Resources/css/eAccounts.css" rel="stylesheet" type="text/css" />
        <link href="/Resources/css/Forum.css" rel="stylesheet" type="text/css" />
    
        <script type="text/javascript" src="/Resources/js/eAccounts.js"></script>
        <script type="text/javascript" src="/Resources/js/eAccounts.Desktop.js"></script>
    
        <asp:ContentPlaceHolder ID="HeadContent" runat="server" />
    </head>
    
    <body>
        <asp:ContentPlaceHolder ID="MainContent" runat="server" />
    </body>
    </html>
  4. #4
    Thank you. I tested, it works for me. The selected file is being saved.

    What Ext.NET version are you using?
  5. #5
    Hey,

    We are using Ext 1.7
  6. #6
    I tested with v1.7. It works for me.

    Could you, please, test exactly the following?

    Master Page
    <%@ Master Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head runat="server">
        <title>Ext.NET v1 Example</title>
    
        <ext:ResourcePlaceHolder runat="server" />
    
        <asp:ContentPlaceHolder ID="HeadContent" runat="server" />
    </head>
    <body>
        <asp:ContentPlaceHolder ID="MainContent" runat="server" />
    </body>
    </html>
    Content Page
    <%@ Page Language="C#" MasterPageFile="Site1.Master" %>
    
    <asp:Content ContentPlaceHolderID="HeadContent" runat="server">
        <script runat="server">
            protected void FileUploadField_FileSelected(object sender, DirectEventArgs e)
            {
                this.FileUploadField1.PostedFile.SaveAs("C:\\Documents\\TESTFILE.txt");
            }
        </script>
    </asp:Content>
    
    <asp:Content ContentPlaceHolderID="MainContent" runat="server">
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:FileUploadField ID="FileUploadField1" runat="server" Width="300">
                <DirectEvents>
                    <FileSelected OnEvent="FileUploadField_FileSelected" IsUpload="true" />
                </DirectEvents>
            </ext:FileUploadField>
        </form>
    </asp:Content>
  7. #7
    I had to add a few lines to the master page in order to be able to navigate to that page:

    Required for main page to load:
    <title>
            <asp:ContentPlaceHolder ID="TitleContent" runat="server" />
    </title>
    Manages the opening of subwindows:
    <script type="text/javascript" src="/Resources/js/eAccounts.Desktop.js"></script>
    Same result as before.
  8. #8
    When i break into the FileSelected function, I find my file at:

    this -> Request -> Files -> _filesAwaitingValidation[0]
  9. #9
    I guess there might be some important thing on your side which causes the issue.

    So, I posted the exact example which I am trying with. It doesn't reproduce the issue for me.

    I do not have this script.
    <script type="text/javascript" src="/Resources/js/eAccounts.Desktop.js"></script>
    I am not sure why this is required:
    <asp:ContentPlaceHolder ID="TitleContent" runat="server" />
    because it is absent in your content page.

    It is confusing.

    To help you we need something to get it reproducible on our side.

    Quote Originally Posted by neat View Post
    this -> Request -> Files -> _filesAwaitingValidation[0]
    Hmm, does the file not exceed the size limitation? How big is the file?
  10. #10
    Quote Originally Posted by Daniil View Post
    I guess there might be some important thing on your side which causes the issue.
    It is a rather large application that starts off from a desktop-like environment, opening windows from there. I can not alter the large-scale behaviour of the program nor share much of the source code.

    HeadContent is needed for desktop to appear and the JS is responsible for finding and opening the desktop windows.

    Quote Originally Posted by Daniil View Post
    Hmm, does the file not exceed the size limitation? How big is the file?
    The file I am currently testing with is a < 1KB text file.
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 0
    Last Post: Sep 27, 2012, 7:16 PM
  2. Replies: 0
    Last Post: Dec 01, 2011, 6:43 AM
  3. FileUploadField help
    By osxboy in forum 1.x Help
    Replies: 0
    Last Post: Jul 26, 2010, 9:50 AM
  4. Replies: 1
    Last Post: Jun 08, 2010, 11:38 AM
  5. FileUploadField
    By matthaus in forum 1.x Help
    Replies: 0
    Last Post: Jun 01, 2009, 6:05 AM

Tags for this Thread

Posting Permissions