我試圖在代碼點火器中下載上傳的文件,但它不起作用。 這是我的控制器(download.php)。如果有人能舉一個例子高度評價。使用代碼點火器下載上傳的文件
<?php
class Download extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->helper(array('form', 'url'));
}
public function index() {
$this->load->view('vwHomeHeader', $data);
$this->load->view('vwHomeMenu', $data);
$this->load->view('download', $data);
$this->load->view('vwHomeFooter', $data);
}
public function download ($file_path = "") {
$this->load->helper('download');
$data['download_file'] = $file_path;
$this->load->view("download",$data);
redirect(current_url(), "refresh");
}
}
?>
這裏是視圖文件(的download.php)
<?php
if(! empty($download_file))
{
$data = file_get_contents(base_url("/upload/".$download_file));
$name = $download_file;
force_download($name, $data);
}
?>
感謝
請描述預期的行爲和實際的 – YakovL