Results 1 to 6 of 6

Thread: Uploading a file response issue

  1. #1
    Sencha Premium Member
    Join Date
    Apr 2009
    Posts
    110

    Question Uploading a file response issue

    I am trying to upload a file to the server using Ext. The file uploads fine but I am having trouble with the response. It does not seem to matter how i set the response it always seems to get returned as xml if i use a .net web service. I understand this maybe a limitation of a web service as it requires a json request in order to respond with a json response for some reason.

    However I then went on to try and do the same with a generic handler (.ashx) file and yet again it does not seem to matter how i set the response it is not handled correctly. In firefox it tries to open the response as a file. My json string is inside this file. In IE i get an error.

    Has anyone come across this. I have copied my code from http://dev.sencha.com/deploy/dev/exa...le-upload.html

  2. #2
    Sencha Developer
    Join Date
    Sep 2008
    Location
    Antioch, IL
    Posts
    1,516

    Default

    What is the "Content-Type" of your response? I think it needs to be application/json in order to prevent the download popup.

  3. #3
    Sencha Premium Member
    Join Date
    Apr 2009
    Posts
    110

    Default

    Thanks for your reply.

    yes it is application/json.

    Its incredibly weird. Uploading files to the server is something I have implemented many times in my life. I cannot understand why this is happening at all.

  4. #4
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    The response header should have Content-disposition:inline to avoid a 'Save as' dialog.

    Also, specifically for a file upload the response should be Content-type:text/html.

  5. #5
    Sencha Premium Member
    Join Date
    Apr 2009
    Posts
    110

    Default

    Quote Originally Posted by Condor View Post
    The response header should have Content-disposition:inline to avoid a 'Save as' dialog.

    Also, specifically for a file upload the response should be Content-type:text/html.
    Thanks condor but this does not work in my situation. Out of interest, why should a file upload have a response type of text/html.

  6. #6
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Ext can't use XmlHttpRequest for file uploads, so it uses a form submit to a hidden IFRAME.

    The result is loaded in the IFRAME, so it must be valid HTML.

    Example return values:
    HTML Code:
    <html>
    <body>
    {
      "success": true,
      "message": "Text needs to be HTML escaped, e.g. &amp; &lt; &gt;"
    }
    </body>
    </html>
    HTML Code:
    <html>
    <body>
    <textarea>
    {
      "success": true,
      "message": "Text in a TEXTAREA doesn't need to be HTML escaped, e.g. & < >"
    }
    </textarea>
    </body>
    </html>

Similar Threads

  1. Uploading a file response issue
    By Chods in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 10 Aug 2010, 10:03 AM
  2. Uploading file and getting list of java objects as response
    By parit in forum Ext GWT: Discussion
    Replies: 2
    Last Post: 31 May 2010, 2:08 AM
  3. File Uploading
    By footballermahesh in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 14 Oct 2009, 3:26 AM
  4. Strange response after uploading files
    By lobo-tuerto in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 15 Feb 2008, 8:28 AM
  5. Response data when uploading file with form
    By ahoekie in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 23 May 2007, 3:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •