View Full Version : How do I make a popup "Save as" dialog box appear using Ext.Button for example?

1 Mar 2011, 6:48 PM
Yes, here is I have a php file which will show a popup "Save as" dialog box to save the excel file:

$filename ="myexcel.xls";
$contents = "hello \t extjs \t sencha \t \n";

header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename='.$filename);
header('Cache-Control: max-age=0');

echo $contents;

In a normal condition when I am request that file (say in http://localhost/popup.php), it will show a popup "Save as" dialog box.

BUT, all I need is to request that file (popup.php) via ExtJS component (say it an Ext.Button). Here is the code:

xtype: 'button'
,text: 'Export to Excel'
,handler: function() {
url: './popup.php'

The result is: request is complete, nothing broken/fail, the headers are ok. BUT the popup "Save as" dialog box wont appears x___x

Any idea?

Thank you before.

5 Mar 2011, 2:00 PM
what you should do is create a hidden iframe and set the source to that iframe to the PHP file that creates the binary. That will force the browser to show the typical download dialog.

5 Mar 2011, 2:24 PM
Checkout Saki's example:

Form/Downloading Files