When trying to download a text file from the new files plugin for groupjive the file is opened in a browser window instead of showing the download box. We contacted our hosting company and have been told that in order to prevent file to open in a browser and open a download dialog, we have to set the content type at the application level. So is not something handled by the server but from php "Content-Transfer-Encoding" and "Content-Type".
This is a script that worked for us in a previous situation:
<?php
function Mext2mime($ext) {
$map = array(
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'gif' => 'image/gif',
'png' => 'image/png',
'zip' => 'application/zip',
'txt' => 'text/plain',
'doc' => 'application/msword',
'docx' => 'application/msword',
'gz' => 'application/x-gzip',
'tgz' => 'application/x-compressed-tar',
'pdf' => 'application/pdf'
);
if (isset($map[$ext])) {
return $map[$ext];
}
// return 'x-extension/' . $ext;
// return 'application/octet-stream';
return 'application/force-download';
}
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=\"".$_REQUEST."\"");
header("Content-Type: ".Mext2mime($_REQUEST));
header("Content-Transfer-Encoding: binary");
header("Content-Length:".$_REQUEST);
?>
Is it possible to include this feature on new gj release?