Fileupload after Save Dialog issue

  1. #1

    Fileupload Controls Shows Save Dialog after upload

    Hello everyone, i have a problem with the file upload functionality. I'm using the MVC pattern in my application, as far as the file upload procedure goes, it's doing what's supposed to do (it's uploading the file). The problem i'm having is after the file is uploaded to the server and then the AjaxResult returns the value. After the value is returned I get the File Download popup window, I have followed the instructions on some of the post in this Forum but they don't work for me ( I don't know why). Below you can see my code.

    PropForSaleWin.ascx

    <ext:Window 
        ID="UploadFileEditor" 
        runat="server" 
        Title="Property For Sale" 
        Icon="House"
        Width="560" 
        Height="450" 
        Modal="true"
        Hidden="true"
        Resizable="false">
            <AutoLoad 
                Url="/Home/PropForSale/" 
                Mode="IFrame" 
                TriggerEvent="show" 
                ReloadOnEvent="true" 
                ShowMask="true" 
                MaskMsg="Loading Property Info...">
            </AutoLoad>
        <Buttons>
            <ext:Button ID="btnTest" runat="server" Text="Save">
                <Listeners>
                    <Click Handler="#{UploadFileEditor}.iframe.dom.contentWindow.saveInfo();" />
                </Listeners>
            </ext:Button>
        </Buttons>
        
    </ext:Window>

    PropForSale.aspx
    
                <ext:FormPanel 
                    ID="frmFileUpload"            
                    Title="Image Upload"
                    runat="server"
                    Frame="false"
                    AutoHeight="true"
                    MonitorValid="true"
                    PaddingSummary="20px 10px 0 10px"            
                    Border="false"
                    LabelWidth="70"
                    FileUpload="true"            
                    Url="/Data/UploadPropertyImage/">
                    <Items>
                        <ext:TextField
                            ID="AttachmentName"
                            runat="server"
                            FieldLabel="File Name" />
                        <ext:FileUploadField 
                            ID="TheFileUploadField"
                            runat="server" 
                            EmptyText="Select an image"
                            FieldLabel="File"
                            ButtonText=""
                            Icon="ImageAdd">
                        </ext:FileUploadField>
                    </Items>
                </ext:FormPanel>
    Controler Code

    
            public AjaxResult UploadPropertyImage()
            {            
                foreach (string file in Request.Files)
                {
                    HttpPostedFileBase files = Request.Files[file];
                    string fileName = files.FileName;
                    if (files.ContentLength > 0)
                    {
                        string filePath = Path.Combine(@"\\formsSrv\www\prop\uploadFiles", Path.GetFileName(files.FileName));
                        files.SaveAs(filePath);
                    }
                }
    
                AjaxResult response = new AjaxResult();
                response.IsUpload = true;
                return response;
            }
    Last edited by reyonlines; Sep 23, 2010 at 4:14 PM.
  2. #2

    Hey guys any thought on this

    Does anyone have an idea about this problem with the FileUpload control?
  3. #3

    solved yet?

    Bumping...

    Is this solved yet? I'm getting the same issue. I think the problem is that browsers are wrapping the JSON response and EXT doesn't know how to handle it. IE shows a download prompt. Chrome just errors out and gets stuck showing the wait message.

    I started another thread for this just before I found this one.

    http://forums.ext.net/showthread.php...ected-token-lt
    Last edited by craig2005; Jan 02, 2011 at 7:33 AM.
  4. #4
    Hi,

    I cannot reproduce it, for me all works fine

    Here is my test case
    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
    <%@ 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></title>
    </head>
    <body>
           <ext:ResourceManager ID="ResourceManager1" runat="server" /> 
           
           <ext:FormPanel
                ID="frmFileUpload"           
                Title="Image Upload"
                runat="server"
                Frame="false"
                AutoHeight="true"
                Width="300"
                MonitorValid="true"
                PaddingSummary="20px 10px 0 10px"           
                Border="false"
                LabelWidth="70"
                FileUpload="true"                      
                Url="/Test/UploadPropertyImage/">
                <Items>
                    <ext:TextField
                        ID="AttachmentName"
                        runat="server"
                        Width="200"
                        FieldLabel="File Name" />
                    <ext:FileUploadField
                        ID="TheFileUploadField"
                        runat="server"
                        EmptyText="Select an image"
                        FieldLabel="File"
                        ButtonText=""
                        Width="200"
                        Icon="ImageAdd">
                    </ext:FileUploadField>
                </Items>
                <Buttons>
                    <ext:Button runat="server" Text="Upload 1">
                        <Listeners>
                            <Click Handler="#{frmFileUpload}.getForm().submit();" />
                        </Listeners>
                    </ext:Button>
                    
                    <ext:Button ID="Button1" runat="server" Text="Upload 2">
                        <DirectEvents>
                            <Click Url="/Test/UploadPropertyImage/" />
                        </DirectEvents>
                    </ext:Button>
                </Buttons>
            </ext:FormPanel>
    </body>
    </html>
    public AjaxResult UploadPropertyImage()
            {           
                AjaxResult response = new AjaxResult();
                response.IsUpload = true;
                return response;
            }
  5. #5

    switched to AjaxResult

    I switched to ajaxresult and it is now somewhat working. The problem is that it keeps hitting the failure condition now. What would trigger this? Why would it not hit the success condition if a result is coming back?

    I'm not sure why this is so difficult. I've been using YUI and Jquery for years and never have this many problems. There are so many ins and outs and no documentation. All that's available is uncommented examples and this forum. So I apologize for all the questions.

    Luckily you guys are good at responding to posts :-)
  6. #6

    figured it out

    ok, i figured it out.

    For forms, you need to use the AjaxFormResult. Just using AjaxResult will not work. I'm not sure how you got the above example to work correctly without the AjaxFormResult.

Similar Threads

  1. Replies: 1
    Last Post: Nov 02, 2012, 4:07 AM
  2. Save as dialog on client side for image
    By vishal.jhala@gmail.com in forum 1.x Help
    Replies: 0
    Last Post: Aug 06, 2011, 8:02 PM
  3. [CLOSED] Save Dialog v0.8.1
    By cobiscorp in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Aug 10, 2010, 9:29 AM
  4. Get the value from prompt dialog and save
    By CoolNoob in forum 1.x Help
    Replies: 5
    Last Post: Oct 23, 2009, 2:13 PM
  5. [CLOSED] Save as dialog?
    By Jurke in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 01, 2009, 12:53 PM

Posting Permissions