Highway to PSR2
[openemr.git] / interface / cmsportal / upload_form_show.php
blobbca694a5fa22115653074dc715f14bb751887a3e
1 <?php
2 /**
3 * View a file upload from the CMS Patient Portal.
5 * Copyright (C) 2014 Rod Roark <rod@sunsetsystems.com>
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
18 * @package OpenEMR
19 * @author Rod Roark <rod@sunsetsystems.com>
25 require_once("../globals.php");
26 require_once("portal.inc.php");
28 $uploadid = $_REQUEST['id'];
30 if (!empty($_REQUEST['messageid'])) {
31 $result = cms_portal_call(array('action' => 'getmsgup', 'uploadid' => $uploadid));
32 } else {
33 $result = cms_portal_call(array('action' => 'getupload', 'uploadid' => $uploadid));
36 if ($result['errmsg']) {
37 die(text($result['errmsg']));
40 $filesize = strlen($result['contents']);
42 header('Content-Description: File Transfer');
43 header('Content-Transfer-Encoding: binary');
44 header('Expires: 0');
45 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
46 header('Pragma: public');
47 header("Content-Disposition: attachment; filename=\"{$result['filename']}\"");
48 header("Content-Type: {$result['mimetype']}");
49 header("Content-Length: $filesize");
51 // With JSON-over-HTTP we would need to base64_decode the contents.
52 echo $result['contents'];