From d99ac01040e8f442d1f625f489ee66a9a30da622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Chapeaux?= Date: Tue, 28 Aug 2001 10:45:23 +0000 Subject: [PATCH] improved mime types and http headers used when exporting dumps to files --- ChangeLog | 3 +++ tbl_dump.php3 | 18 +++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8bca106a4..ca1e008e1 100755 --- a/ChangeLog +++ b/ChangeLog @@ -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 * db_stats.php3: fixed the sql query so that the script won't die, even if diff --git a/tbl_dump.php3 b/tbl_dump.php3 index 03478ded3..db59c0fd8 100755 --- a/tbl_dump.php3 +++ b/tbl_dump.php3 @@ -98,25 +98,29 @@ if (empty($asfile)) { // Download else { - // Defines filename and extension + // Defines filename and extension, and also mime types if (!isset($table)) { $filename = $db; } else { $filename = $table; } if (isset($bzip) && $bzip == 'bzip') { - $ext = 'bz2'; + $ext = 'bz2'; + $mime_type = 'application/x-bzip'; } else if (isset($gzip) && $gzip == 'gzip') { - $ext = 'gz'; + $ext = 'gz'; + $mime_type = 'application/x-gzip'; } else if ($what == 'csv' || $what == 'excel') { - $ext = 'csv'; + $ext = 'csv'; + $mime_type = 'text/x-csv'; } else { - $ext = 'sql'; + $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