Skip to content

Commit

Permalink
Minor changes to send_file():
Browse files Browse the repository at this point in the history
* Wrote phpdoc comment that documents all parameters
* Added $mimetype param (default empty) that can be used if MIME type is already known and doesn't need guessing from filename
  • Loading branch information
sam_marshall committed Jul 5, 2006
1 parent 00aeaec commit ba75ad9
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lib/filelib.php
Expand Up @@ -203,12 +203,23 @@ function get_mimetype_description($mimetype,$capitalise=false) {
}

/**
* @PARAM $filter int 0=no filtering, 1=all files, 2=html files only
* Handles the sending of file data to the user's browser, including support for
* byteranges etc.
* @param string $path Path of file on disk (including real filename), or actual content of file as string
* @param string $filename Filename to send
* @param int $lifetime Number of seconds before the file should expire from caches (default 24 hours)
* @param int $filter 0 (default)=no filtering, 1=all files, 2=html files only
* @param bool $pathisstring If true (default false), $path is the content to send and not the pathname
* @param bool $forcedownload If true (default false), forces download of file rather than view in browser/plugin
* @param string $mimetype Include to specify the MIME type; leave blank to have it guess the type from $filename
*/
function send_file($path, $filename, $lifetime=86400 , $filter=0, $pathisstring=false, $forcedownload=false) {
function send_file($path, $filename, $lifetime=86400 , $filter=0, $pathisstring=false, $forcedownload=false, $mimetype='') {
global $CFG;

$mimetype = $forcedownload ? 'application/x-forcedownload' : mimeinfo('type', $filename);
// Use given MIME type if specified, otherwise guess it using mimeinfo.
// Always use application/x-forcedownload if that's requested.
$mimetype = $forcedownload ? 'application/x-forcedownload' :
($mimetype ? $mimetype : mimeinfo('type', $filename));
$lastmodified = $pathisstring ? time() : filemtime($path);
$filesize = $pathisstring ? strlen($path) : filesize($path);

Expand Down

0 comments on commit ba75ad9

Please sign in to comment.