【发布时间】:2014-09-28 16:30:50
【问题描述】:
我想从浏览器运行 URL 并获取位于我的项目之外的文件内容,例如:/home/fessy/file.txt
我使用 codeigniter 和学说。
我有一个方法:
class Api extends REST_Controller {
// ....
public function get_file_content_get(){
var_dump(array('ftp_path' => $this->uri->segments));
$name = $this->uri->segment(3);
$rootPath = $this->uri->segment(4);
$file = file_get_contents("$rootPath/$name.txt", FILE_USE_INCLUDE_PATH);
// $this->_response('success', array('file_contents' => $file));
}
所以我将我的 URL 生成为:
site.com/index.php/api/get_file_content_get/118130/%2Fhome%2Ffessy%2Ffile.txt
但我得到一个错误:
<xml>
<status/>
<error>Unknown method.</error>
</xml>
当我将超类从REST_Controller 更改为CI_Controller 时,我成功调用了get_file_content_get 方法。
我无法让site.com/index.php/api/get_file_content_get/ 调用index()
我做错了什么?
谢谢,
【问题讨论】:
标签: codeigniter doctrine