user3405072
user3405072

Reputation: 1

PHP Create Download Link

<?php
    $file = SEVENCE_DATA_ROOT."/resource/devdemo/promo_card.tiff";
    header('Content-Description: File Transfer');
    header('Content-type: application/tiff');
    header("Content-Type: application/force-download");// some browsers need this
    header("Content-Disposition: attachment; filename=promo_card.tiff");
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;
?>

My issue is that the download image can't be viewed. Can anyone help me with this issue?

Upvotes: 0

Views: 173

Answers (1)

Daniel W.
Daniel W.

Reputation: 32260

Content-Type: application/force-download");// some browsers need this

No browser does need this. It's a dirty glitch..

Reasons why your file cannot be opened:

  1. You have a space or invisible characters at the beginning of your script

  2. the path you are loading the file from might be wrong and it doesn't even read from it (what size is the downloaded file?)

  3. the file simply is corrupt

  4. you don't have a tiff-viewer

The correct mime type is image/tiff (instead of application/tiff)

Upvotes: 1

Related Questions