From 7e4dfd67f0e1a1293c6cbbedd88c9100b0204c92 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Thu, 2 Oct 2014 17:53:25 +0200 Subject: [PATCH] tos can be download as pdf or txt now --- web/doc_download.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/web/doc_download.php b/web/doc_download.php index d447c19..9e86ef1 100644 --- a/web/doc_download.php +++ b/web/doc_download.php @@ -9,16 +9,23 @@ function main() return(FALSE); } - $fname = sprintf("%s%s.pdf", $G_doc_path, basename($_GET['doc'])); + $ext = "pdf"; + $cont_type = "application/octet-stream"; + if (isset($_GET['ext']) && ($_GET['ext'] == "txt")) { + $cont_type = "plain/text"; + $ext = $_GET['ext']; + } + + $fname = sprintf("%s%s.%s", $G_doc_path, basename($_GET['doc']), $ext); if (! file_exists($fname)) { return(FALSE); } - header("Content-Type: application/octet-stream"); + header(sprintf("Content-Type: %s", $cont_type)); header(sprintf("Content-Disposition: attachment; filename=brisk_%s", basename($fname))); readfile($fname); return(TRUE); } main(); -?> \ No newline at end of file +?> -- 2.17.1