Пример #1
0
// 	$this->view->title = array('File','Create',' #' . $f->link);
// }
$f = new Base_File($_POST['id']);
switch (strtolower($_POST['a'])) {
    case 'delete':
        $f->delete();
        Session::flash('info', 'File Deleted');
        Radix::redirect('/file');
        break;
    case 'upload':
        $f->copyPost($_FILES['file']);
        //if ($f) {
        //	$f['id'] = intval($_POST['id']);
        //	$f['link'] = $_POST['link'];
        //	$f->import($_FILES['file']);
        $f->save();
        Session::flash('info', 'File #' . $f['id'] . ' Saved');
        // } else {
        // 	Session::flash('fail', 'Invalid Input');
        // }
        break;
}
// Redirect Out
if (!empty($f['link'])) {
    if (preg_match('/(contact|invoice|workorder):(\\d+)/', $f['link'], $m)) {
        $page = '/' . $m[1] . '/view?' . substr($m[1], 0, 1) . '=' . $m[2];
        Radix::redirect($page);
    }
}
Radix::redirect('/file');
Пример #2
0
<?php

/**
    @file
    @brief File Controller
*/
$f = new Base_File(intval($_GET['id']));
if (!is_file($f['path'])) {
    Session::flash('fail', 'File not Found');
    Radix::redirect($_SERVER['HTTP_REFERER']);
}
// $this->force_download = true;
header('Cache-Control: private,must-revalidate,max-age=5', true);
//if (empty($this->force_download)) {
header('Content-Disposition: attachment; filename="' . $f['name'] . '"', true);
//} else {
//  header('Content-Disposition: inline; filename="' . $this->name . '"',true);
//}
header('Content-Length: ' . filesize($f['path']), true);
header('Content-Type: ' . $f['kind'], true);
$fh = fopen($f['path'], 'r');
fpassthru($fh);
exit(0);