improved mime types and http headers used when exporting dumps to files

This commit is contained in:
Loïc Chapeaux
2001-08-28 10:45:23 +00:00
parent 33109f329b
commit d99ac01040
2 changed files with 14 additions and 7 deletions

View File

@@ -13,6 +13,9 @@ $Source$
* main.php3:
- lines 425-426: form is submitted with post method;
- lines 431-447: languages are sorted by their true names.
* tbl_dump.php3, lines 101-123: improved mime types and http headers used
when exporting dumps to files thanks to Dan Allen &
Ignacio Vazquez-Abrams.
2001-08-28 Olivier M<>ller <om@omnis.ch>
* db_stats.php3: fixed the sql query so that the script won't die, even if

View File

@@ -98,7 +98,7 @@ if (empty($asfile)) {
// Download
else {
// Defines filename and extension
// Defines filename and extension, and also mime types
if (!isset($table)) {
$filename = $db;
} else {
@@ -106,17 +106,21 @@ else {
}
if (isset($bzip) && $bzip == 'bzip') {
$ext = 'bz2';
$mime_type = 'application/x-bzip';
} else if (isset($gzip) && $gzip == 'gzip') {
$ext = 'gz';
$mime_type = 'application/x-gzip';
} else if ($what == 'csv' || $what == 'excel') {
$ext = 'csv';
$mime_type = 'text/x-csv';
} else {
$ext = 'sql';
$mime_type = 'application/octetstream';
}
// Send headers
header('Content-Type: application/octetstream');
header('Content-Disposition: filename="' . $filename . '.' . $ext . '"');
header('Content-Type: ' . $mime_type);
header('Content-Disposition: attachment; filename="' . $filename . '.' . $ext . '"');
header('Pragma: no-cache');
header('Expires: 0');
} // end download