Skip to content

Commit

Permalink
document sending, no content dispoposition attachment for pictures; see
Browse files Browse the repository at this point in the history
  • Loading branch information
orthagh committed Aug 26, 2016
1 parent 9853463 commit fc93633
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion inc/document.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,21 @@ function send() {
if (!file_exists($file)) {
die("Error file ".$file." does not exist");
}

// don't download picture files, see them inline
$attachment = "";
$filename_parts = explode(".", $this->fields['filename']);
$extension = array_pop($filename_parts);
$extension = strtolower($extension);
if (!in_array($extension, array('jpg', 'png', 'gif', 'bmp'))) {
$attachment = " attachment;";
}

// Now send the file with header() magic
header("Expires: Mon, 26 Nov 1962 00:00:00 GMT");
header('Pragma: private'); /// IE BUG + SSL
header('Cache-control: private, must-revalidate'); /// IE BUG + SSL
header("Content-disposition: attachment; filename=\"".$this->fields['filename']."\"");
header("Content-disposition:$attachment filename=\"".$this->fields['filename']."\"");
header("Content-type: ".$this->fields['mime']);

readfile($file) or die ("Error opening file $file");
Expand Down

0 comments on commit fc93633

Please sign in to comment.