[CLOSED] [1.0] - MVC - How to get FileUploadField's Content

  1. #1

    [CLOSED] [1.0] - MVC - How to get FileUploadField's Content

    Hi,

    Is there a way to pass the content (byte[]) of the FileUploadFiled (after a file is selected) to a Controller?


    [Update]
    I have the IsUpload="true" for the DirectEvent, I think I can access the file content in the controller using this.Request.Files but when return, the browser prompt the user whether to open the file... in which I should not prompt at all.


    Thank.
  2. #2

    RE: [CLOSED] [1.0] - MVC - How to get FileUploadField's Content

    Hi,

    Can you post Controller action code?
  3. #3

    RE: [CLOSED] [1.0] - MVC - How to get FileUploadField's Content

    Controller
            public AjaxResult GetFile()
            {
                Request.Files[0].SaveAs("c:\\abc.xls");
                AjaxResult result = new AjaxResult();            
                return result;
            }

    Markup
    <ext:FormPanel runat="server" Layout="Fit">
                <Items>
                    <ext:FileUploadField ID="fileupload" runat="server" Icon="PageExcel" ButtonText="Browse">
                        <Listeners>
                            <FileSelected Handler="#{Store_ImportExcel}.reload();" />
                        </Listeners>
                    </ext:FileUploadField>
                    <ext:Button runat="server" Text="ss">
                        <DirectEvents>
                            <Click Url="/Ticket/GetFile/" IsUpload="true" CleanRequest="true" Method="POST" >
                            </Click>
                        </DirectEvents>
                    </ext:Button>                
                </Items>
            </ext:FormPanel>
  4. #4

    RE: [CLOSED] [1.0] - MVC - How to get FileUploadField's Content

    Ah, figured it out. Have to set the IsUpload flag to true in the Controller Action

    public AjaxResult GetFile()
    {
      Request.Files[0].SaveAs("c:\\abc.xls");
      AjaxResult result = new AjaxResult();   
      result.IsUpload = true;         
      return result;
    }

Similar Threads

  1. [CLOSED] FileUploadField in GridPanel
    By kenanhancer in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Sep 20, 2011, 2:43 PM
  2. How to use ASP.NET content inside EXT.NET content
    By Janaka360 in forum 1.x Help
    Replies: 2
    Last Post: May 09, 2011, 4:21 AM
  3. Replies: 0
    Last Post: Oct 19, 2010, 7:39 AM
  4. [CLOSED] FileUploadField
    By majestic in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 08, 2010, 11:31 AM
  5. [CLOSED] FileUploadField
    By Sharon in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Jun 03, 2009, 3:31 AM

Posting Permissions