Page 1 of 1

Headers that makes the browser download the file.

Posted: Thu Oct 31, 2002 2:47 am
by Takuma
I'm making a database backuper and I want for the user to be able to download the sql query file afterwards. Which headers do I send in this case to the browser?

Posted: Thu Oct 31, 2002 6:53 am
by volka
what do you send? The result of an export like

Code: Select all

CREATE TABLE `whatever` (
....
) TYPE=MyISAM;
....
INSERT INTO whatever VALUES("1", "2");
INSERT INTO whatever VALUES("2", "3");
....
if so I suggest CXII. Zlib Compression Functions and the mime-type is application/x-gzip or application/zip

Posted: Sat Nov 09, 2002 2:36 pm
by Takuma
So how do I tell browser to download to the zgip file?

Posted: Sat Nov 09, 2002 9:17 pm
by volka
really depends on the average file size.
If bandwidth and/or storage is not the problem you can try it with

Code: Select all

<?php
$filename = 'export.sql'; // e.g.
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$filename);
readfile($filename);?>
first....