问题描述
快速解释,但我不能让它工作:
Fast to explain, but i cant 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 are show (well you now, the strange codified content :)I think it is simple enought, i just want the file downloaded with no other efect, am i doing something wrong?
推荐答案
只是一个可能会遇到此问题的人的注释:确保您在第一个参数提供的文件名上有一个文件扩展名为 force_download()
。
Just a note to anyone else who may be having this problem: Make sure you have a file extension on the filename you supply for the first argument to force_download()
.
CodeIgniter使用这个来设置MIME类型,而且似乎不起作用。
CodeIgniter uses this to set the MIME type, and it doesn't seem to work without.
这篇关于CodeIgniter - force_download()问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!