CodeIgniter-force_download()无输出 [英] CodeIgniter - force_download() no output

查看:90
本文介绍了CodeIgniter-force_download()无输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

快速解释一下,但我无法使其工作:

Fast to explain, but I can't get it to work:

在此简单代码中,force_download函数根本不会产生任何输出。

In this simple code, the function force_download simply doesn't make any output.

$this->load->helper('download');
$data = file_get_contents("modulos/".$filename); // Read the file's contents
force_download($filename, $data);
echo $data."/".$filename;

在这里,我只是得到一个白色的屏幕,但是文件内容显示了(很奇怪,编码的内容:)
我认为这很简单,我只希望下载的文件没有其他效果,我做错了吗?

Here I just get a white screen, but the file content is show (well you know, the strange codified content :) I think it is simple enough, I just want the file downloaded with no other effect, am I doing something wrong?

推荐答案

这将与您一起使用

$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`

这篇关于CodeIgniter-force_download()无输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆