【问题标题】:Codeigniter, sending data with urlCodeigniter,使用 url 发送数据
【发布时间】:2015-12-14 20:49:14
【问题描述】:

我有一个 codeigniter 控制器,它有一个索引页面,它接受 4 个参数,如以下参数:

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Upload extends CI_Controller {

    public function index($file_name = NULL, $PID = NULL, $Email = NULL, $password = NULL){
        if($file_name === NULL){
           $this->output    
                ->set_content_type('application/json')
                ->set_output(json_encode(array("status"=> "failure", "message" => "The file name is missing")));          
        }else if($PID === NULL){
            $this->output    
                ->set_content_type('application/json')
                ->set_output(json_encode(array("status"=> "failure", "message" => "The PID is missing")));
        }else if($Email === NULL){
            $this->output    
                ->set_content_type('application/json')
                ->set_output(json_encode(array("status"=> "failure", "message" => "The email is missing")));
        }else if($password === NULL){
            $this->output    
                ->set_content_type('application/json')
                ->set_output(json_encode(array("status"=> "failure", "message" => "The password is missing")));
}else{
$this->output    
                ->set_content_type('application/json')
                ->set_output(json_encode(array("status"=> "success", "message" => "Upload Done")));
}
}
}

route.php 文件看起来像:

$route['Upload/(:any)'] = "Upload/index/$1";
$route['Upload/(:any)/(:any)'] = "Upload/index/$1/$2";
$route['Upload/(:any)/(:any)/(:any)'] = "Upload/index/$1/$2/$3";
$route['Upload/(:any)/(:any)/(:any)/(:any)'] = "Upload/index/$1/$2/$3/$4";

我想调用 Controller 索引方法并提供所有数据,如下所示:

www.mysite.com/Upload/myfile.csv/367/myemail@gmail.com/mypass;23!ù/o*

如果我这样运行,我会得到:

遇到错误

您提交的 URI 包含不允许的字符。

加密每个数据并将它们全部发送到上述 URL 中的最佳方法是什么?

我试过base64但同样的问题,请问有什么想法吗?

谢谢

【问题讨论】:

    标签: php codeigniter url


    【解决方案1】:

    嘿伙计,只需更改您的config.php 把它放在你允许的字符上

    $config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-\=';
    

    你可以根据自己的需要改变

    $config['permitted_uri_chars'] = 'a-z 0-9~%.:&_\-'; 
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-04-05
    • 2021-05-09
    • 2017-01-12
    • 2015-04-15
    • 1970-01-01
    • 2017-09-04
    • 1970-01-01
    相关资源
    最近更新 更多