[CLOSED] MVC upload file in FormPanel

  1. #1

    [CLOSED] MVC upload file in FormPanel

    Hi,

    I'm trying to upload a file using the FileUploadField in a FormPanel in my MVC app - can anyone suggest how this can be done. I'm not aware of it being possible to upload a file (form with enctype of multipart/form-data) via an AJAX request... Does Ext.NET / ExtJS handle this?

    My markup currently looks like this:

                                        <ext:FormPanel ID="UploadForm" runat="server" Border="false" Url="/LocationData/UploadMap/">
                                        <Items>
                                            <ext:FileUploadField ID="MapUpload" runat="server" Width="300" Icon="Attach" FieldLabel="File"/>
                                            <ext:Button ID="Button3" runat="server" Text="Upload map">
                                                <Listeners>
                                                    <Click Handler="#{UploadForm}.form.submit({ waitMsg : 'Uploading...', params : { id : getRecordId() }, success : uploadMapCompleted, failure : uploadFailureHandler});" />
                                                </Listeners>
                                            </ext:Button>
                                        </Items>
                                        </ext:FormPanel>
    Last edited by Daniil; Jan 20, 2011 at 1:13 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Please set IsUpload="true" for FormPanel
  3. #3
    Hi,

    Sorry, no such property exists
  4. #4
    Hi,

    I think Vladimir meant FileUpload="true".
  5. #5
    I added that property, and now when I submit the form I get a JavaScript error from the Ext.Net generated Javascript....

    The error from WebResource.axd:

    Uncaught SyntaxError: Unexpected token <

    My form looks like this:

    <ext:FormPanel ID="UploadForm" runat="server" Border="false" Url="/LocationData/UploadMap/" FileUpload="true">
    <Items>
        <ext:FileUploadField ID="MapUpload" runat="server" Width="300" Icon="Attach" FieldLabel="File"/>
        <ext:Button ID="Button3" runat="server" Text="Upload image">
            <Listeners>
                <Click Handler="#{UploadForm}.form.submit({ waitMsg : 'Uploading...', params : { id : getRecordId() }, success : uploadMapCompleted, failure : uploadFailureHandler});" />
            </Listeners>
        </ext:Button>
    </Items>
    </ext:FormPanel>
  6. #6
    Hi,

    If you use native FormPanel submit method with file uploading then controller action should return something similar
    public ContentResult UploadMap()
    {
         return Content("<textarea>{success: true}</textarea>");
    }
    Wraping by textarea tags is required when you upload file, in other cases textarea tags must be excluded
  7. #7
    Thanks, that sorted it
  8. #8
    Quote Originally Posted by Vladimir View Post
    Hi,

    If you use native FormPanel submit method with file uploading then controller action should return something similar
    public ContentResult UploadMap()
    {
         return Content("<textarea>{success: true}</textarea>");
    }
    Wraping by textarea tags is required when you upload file, in other cases textarea tags must be excluded

    Hi

    Great Post! really it works.. thanks a lot...

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. Replies: 1
    Last Post: Jun 23, 2011, 9:37 AM
  3. [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
  4. [CLOSED] [1.0] Help with File Upload
    By pdcase in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Sep 13, 2010, 4:16 PM
  5. [CLOSED] Help with file upload
    By smart+ in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Sep 09, 2010, 8:02 PM

Tags for this Thread

Posting Permissions