我需要使用CodeIgniter下载。我尝试使用force_download
函数和download
函数。
具有download
功能,但不能选择要下载的文件夹。使用强制下载功能,浏览器可以下载一个空文件。
$this->load->helper('download');
$path = file_get_contents(base_url()."modulos/".$filename); // get file name
$name = "sample_file.pdf"; // new name for your file
//
force_download($name, $path); // start download
// or
$this->ftp->download($path, '/local/path/to/'.$name);
答案 0 :(得分:0)
$this->ftp->download
将文件从网络服务器下载到客户端。要从 FTP服务器一直下载文件到客户端,您必须组合/链接这两个功能。
$temp_path = $temp_file = tempnam(sys_get_temp_dir(), $name);
$this->ftp->download($path, $temp_path);
$data = file_get_contents($temp_path);
force_download($name, $data);
unlink($temp_path);