2014-09-28 92 views
0

我想从浏览器中运行的网址,让位于我的项目的文件内容,例如:/home/fessy/file.txt无法从URL调用方法,笨

我用笨和学说。

我有一个方法:

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));  
} 

于是我产生了自己的网址为:

site.com/index.php/api/get_file_content_get/118130/%2Fhome%2Ffessy%2Ffile.txt 

但我得到一个错误:

<xml> 
    <status/> 
    <error>Unknown method.</error> 
</xml> 

当我改变超类从REST_ControllerCI_Controller我成功拨打get_file_content_get的方法。

我事件不能得到site.com/index.php/api/get_file_content_get/调用index()

我做错了什么?

感谢,

回答

0

发现问题:

我需要删除_get后缀,因为教义使用这个后缀为GET指标

相反:

site.com/index.php/api/get_file_content_get/118130/%2Fhome%2Ffessy%2Ffile.txt 

应该是:

site.com/index.php/api/get_file_content/118130/%2Fhome%2Ffessy%2Ffile.txt