我试图在代码点火器中下载上传的文件,但它不起作用。 这是我的控制器(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