示例#1
0
文件: file.php 项目: ssrsfs/blg
<?php

/*
	7 april 2011: created from news/article.php
		and original file
*/
// get file id
$fileid = trim(@$_REQUEST['fileid']);
// instantiate download object
$download = new Download_File($fileid);
// validate it
if ($download->exists()) {
    // update the number of times it has been downloaded
    $download->incrementDownloads();
    // send file to user
    $filename = $download->get('filename');
    $fullname = TYPEF_DIR . '/files/public/downloads/' . $filename;
    if (file_exists($fullname) && is_file($fullname)) {
        header('Pragma: public');
        header('Content-Type: application/force-download');
        header('Content-Disposition: attachment; filename="' . $filename . '"');
        readfile($fullname);
        exit;
    }
}
// oops... physical file is missing...
header('HTTP/1.0 404 Not Found');
Typeframe::Redirect('File not found.', Typeframe::CurrentPage()->applicationUri(), 3, false);