RE: [PHP-DB] force to download file
| From: | Lasitha Alawatta | Date: | Tue, 18 Dec 2007 05:49:10 +0000 |
| Subject: | RE: [PHP-DB] force to download file | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-44424@lists.php.net to get a copy of this message | ||
Hi ,
Try with this header.
$export_file = "YourFileName.xls";
ob_end_clean();
ini_set('zlib.output_compression','Off');
header('Pragma: public');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// Date in the past
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
// HTTP/1.1
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
// HTTP/1.1
header ("Pragma: no-cache");
header("Expires: 0");
header('Content-Transfer-Encoding: none');
header('Content-Type: application/vnd.ms-excel;');
// This should work for IE & Opera
header("Content-type: application/x-msexcel");
// This should work for the rest
header('Content-Disposition: attachment;
filename="'.basename($export_file).'"');
Regards,
Lasitha
-----Original Message-----
From: Hiep Nguyen [mailto:hnguyen@jadesterling.com]
Sent: Tuesday, December 18, 2007 12:14 AM
To: php-db@lists.php.net
Subject: [PHP-DB] force to download file
hi all,
i have this on top of my php page:
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: inline; filename=excelfile.xls");
but it is not prompt to save the file instead it opens right in IE.
my question is how do i force the browser prompts to save the file?
thanks
DOTW DISCLAIMER:
This e-mail and any attachments are strictly confidential and intended for the addressee only. If
you are not the named addressee you must not disclose, copy or take
any action in reliance of this transmission and you should notify us as soon as possible. If you
have received it in error, please contact the message sender immediately.
This e-mail and any attachments are believed to be free from viruses but it is your responsibility
to carry out all necessary virus checks and DOTW accepts no liability
in connection therewith.
This e-mail and all other electronic (including voice) communications from the sender's company
are for informational purposes only. No such communication is intended
by the sender to constitute either an electronic record or an electronic signature or to constitute
any agreement by the sender to conduct a transaction by electronic means.