Commit d761c4f5 authored by Robert Lyon's avatar Robert Lyon

Bug 1826284: Allow PDF bulkexport to serve file correctly

For some reason the generated file does not like the 'application/zip'
mimetype being set so we override it and set no Content-Type header
forcing the browser to work it out

behatnotneeded

Change-Id: I85085a18202f6a00a05c560058eaff19d865343c
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent deff2790
......@@ -206,7 +206,12 @@ function bulkexport_submit(Pieform $form, $values) {
// Download the export file once it has been generated
require_once('file.php');
serve_file($zipfile, basename($zipfile), 'application/x-zip', array('lifetime' => 0, 'forcedownload' => true));
$mimetype = 'application/zip; charset=binary';
$options = array('lifetime' => 0, 'forcedownload' => true);
if ($exporttype == 'pdf') {
$options['overridecontenttype'] = 'none';
}
serve_file($zipfile, basename($zipfile), $mimetype, $options);
// TODO: delete the zipfile (and temporary files) once it's been downloaded
}
......
......@@ -155,7 +155,9 @@ function serve_file($path, $filename, $mimetype, $options=array()) {
}
else {
if (isset($options['overridecontenttype'])) {
header('Content-Type: ' . $options['overridecontenttype']);
if ($options['overridecontenttype'] != 'none') {
header('Content-Type: ' . $options['overridecontenttype']);
}
}
else {
header('Content-Type: ' . $mimetype);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment