Downloading File

Description

This example shows how to create a button or link for downloading a file. The example creates hidden helper iframe and hidden form. Iframe is the target of the form submit. Return the correct HTTP headers from the server is crucial.

Result

Main Features

  • very simple
  • mix of Ext/Touch and HTML
  • PHP server side code

Use Cases

Use whenever you need to trigger the browser download mechanism by clicking a button or link.

Source Code

If you want to see the example code, login or sign-up. Free membership is available.
Follow me:

Saki

I'm a well seasoned developer, consultant and educator of web applications based mainly on Sencha libraries, PHP, MySQL and Node.js. Besides (Apple) computers, I love photography and mountain biking.
Follow me:

Latest posts by Saki (see all)

Comments

  1. Mike Bedingfield says

    What if you would like to send some get/post information back to the PHP files? I have tried to add method:’GET’ to the form and also add some hidden items with values but the $_GET on the php side never detects that they have been sent.

    • says

      GET won’t work with forms but POST is no problem. Just add your hidden fields with values to the generated form and check $_POST variable in PHP.

  2. praveen kumar says

    Hi Saki,

    Could you please suggest me to get the failure response of form submit?

    I need to capture failure response and show it as a message alert for users. Thanks for your time.

    Thanks,
    Praveen

  3. Airam Mateos says

    Hi.

    Thanks for your solution. However I need to send headers on form submit because I use an oAuth validation (symfony framework) but it doesn’t work :(
    form.submit({
    headers: {…},
    success: function(){…},
    failure: function(){…}
    });

    If y see the submit parameters on developer tool (chrome) my headers aren’t sent.

    Any idea? Thanks in advice.

We will be happy to hear back from you

Please Login to post a comment