john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

php start download with readfile

php-start-download-with-readfile


<?php
$file = 'monkey.gif';

if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');
    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;
}
?>

  • « php user defined function
  • php server phpinfo global variables user ip and dir »

Published

Feb 6, 2010

Category

php

~31 words

Tags

  • download 12
  • php 82
  • readfile 3
  • start 8
  • with 29