工作我想在代碼點火器框架內使用xsendfile向用戶發送文件。xsendfile只能從索引
它都安裝正確,我的問題是,它似乎只能從路由工作,即使每個頁面都來自index.php無論如何。
這是我的函數:
function _output_file($name, $root_location, $public_location = FALSE)
{
if (function_exists('apache_get_modules') && in_array('mod_xsendfile', apache_get_modules())) {
header ('Content-Description: File Transfer');
header ('Content-Type: application/octet-stream');
if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE") != FALSE) {
header ('Content-Disposition: attachment; filename='.urlencode($name));
} else {
header ('Content-Disposition: attachment; filename="'.$name.'"');
}
//86400 is one day
header ('Expires: '.gmdate('D, d M Y H:i:s', (TIME_NOW + 86400)));
header ('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header ('Pragma: public');
header ('X-Sendfile: '.$root_location);
exit;
} else {
redirect(site_url($public_location));
}
}
如果我把這個在我的index.php頂部並加載它正常工作的根本,但如果我嘗試從domain.com/controller/訪問函數它返回一個404錯誤。
肯定使用index.php文件,因爲如果我用die(「test」)替換函數調用;這顯示在屏幕上。
我相信這是關於什麼權限xsendfile必須訪問該文件,但由於它是從根index.php工作,我會認爲它會有完整的權限,大概是基於請求的網址是什麼,我覺得很奇怪。
所以....有沒有人有任何建議,我怎麼能得到xsendfile工作通過codeigniter,從一個url,如「domain.com/files/get/12」?
我的確意識到這一點,這是一個被稱爲例如另一個函數我在名爲「files」的類中有一個名爲「get」的函數,通過訪問domain.com/files/get然後調用這個函數。對不起,我應該提到的是,我認爲當你說這會從'index.php'通過我想這是一個問題,訪問的URL工作,但不能從控制器這將是顯而易見的 – robjbrain
。你可不可以請刪除downvote? – birderic
你好我的投票被鎖定,除非答案編輯:)(編輯:這不是我小氣,那是錯誤,以便使) – robjbrain