标签: codeigniter

我似乎无法在codeigniter中上传css文件类型

我正在尝试上传css文件用户codigniter的上传类.这是控制器:

public function uploadcssfile() 
{
   $config['upload_path'] = './stylesheets/stores/'.$memberid.'/'; 
   $config['file_name'] = 'main.css';    
   $config['allowed_types'] = 'css';   
   $config['overwrite'] = true;   
   $this->load->library('upload', $config);
   if (! $this->upload->do_upload('filefieldname'))
   {
     die($this->upload->display_errors());
   } 
}
Run Code Online (Sandbox Code Playgroud)

我只想上传一个css类型的文件,但codeigniter总是会出现这个错误:

The filetype you are attempting to upload is not allowed.
Run Code Online (Sandbox Code Playgroud)

css php codeigniter file-upload mime-types

8
推荐指数
1
解决办法
872
查看次数

使用CodeIgniter发送电子邮件时出错

在发送电子邮件时,我收到了一堆这样的错误:

A PHP Error was encountered

Severity: Notice

Message: fwrite(): send of 12 bytes failed with errno=32 Broken pipe

Filename: libraries/Email.php

Line Number: 1846

A PHP Error was encountered

Severity: Notice

Message: fwrite(): send of 39 bytes failed with errno=32 Broken pipe

Filename: libraries/Email.php

Line Number: 1846

A PHP Error was encountered

Severity: Notice

Message: fwrite(): send of 31 bytes failed with errno=32 Broken pipe

Filename: libraries/Email.php

Line Number: 1846
Run Code Online (Sandbox Code Playgroud)

我已按照CodeIgniter用户指南配置SMTP:

$config['protocol']='smtp';  
$config['smtp_host']='ssl0.ovh.net';  
$config['smtp_port']='465';  
$config['smtp_timeout']='10';  
$config['smtp_user']='postmaster%example.com';  
$config['smtp_pass']='password';
$config['mailtype'] = 'html'; …
Run Code Online (Sandbox Code Playgroud)

email freebsd smtp codeigniter

8
推荐指数
3
解决办法
3万
查看次数

如何使用CodeIgniter轻松进行单元测试?

我想用CodeIgniter测试我的控制器/模型.如何使用CodeIgniter完成此操作?

phpunit unit-testing codeigniter

8
推荐指数
1
解决办法
1万
查看次数

将函数中的会话变量传递给codeigniter中的帮助器

这就是我想要做的.这是控制器中的功能

public function get_started()
{
    if(test_login($this->session->all_userdata())) {
        $this->load->view('template');
    } else {
        $this->load->view('error');
    }
}
Run Code Online (Sandbox Code Playgroud)

这是帮手

function test_login($sessdata)
{
    if($sessdata->userdata('is_logged_in')) {
        return true;
    } else {
        return false;
    }
}
Run Code Online (Sandbox Code Playgroud)

我输入is_logged_in了一个布尔会话变量.但是,这不起作用.

我找不到错误.

php codeigniter

8
推荐指数
1
解决办法
7927
查看次数

REST API登录方法

我们正在构建需要所有页面的登录信息的系统.该应用程序被设计为使用codeigniter作为Phil Sturgeon库的Restful应用程序.此库仅使用API​​密钥通过HTTPS连接的每个请求发送api调用来授权api调用.

即使它使用2路认证或仅使用API​​密钥.我正在寻找一段时间是以下场景:

  • 用户首次请求该应用程序(例如:https://www.xyz.com),然后将其重定向到登录页面以检查凭据
  • 用户输入usernam /密码并通过https发送
  • 服务器检查信息是否有效,然后:

    • API KEY应由服务器提供给客户端,作为此用户名标识的资源(这是问题??? !!!)

    • 如何以安全的方式将API密钥发送到客户端?

      • 1)我可以使用会话cookie并在cookie中恢复API KEY,然后在每个即将到来的请求中使用此API KEY(这是暴力的其余的无状态,我不确定它是否足够安全).
      • 2)实际上我不知道其他选择:)如果你能提供帮助,轮到你了

如果你能给出一个例子,那将是一个很大的帮助,因为我找到并阅读了很多文章

:)

authentication rest codeigniter

8
推荐指数
1
解决办法
6305
查看次数

您没有选择要上传的文件.PHP代码点火器

我正在尝试实现一个帖子功能,并希望从php视图中选择消息和图像.我的消息功能正常.但在图像上传时我收到错误You did not select a file to upload.这是我的控制器功能

function post_func()
{
    session_start();
    echo $post_message=$_POST['post'];
    echo $share_with=$_POST['share_with'];
    echo $image=$_POST['image'];
    if($image==null){
        echo "<br/>no image<br/>";  
    }
    else{
        ////////////////////////////////////////////////////////////////////////////////////////

            $config['upload_path'] = './application/css';
            $config['allowed_types'] = 'gif|jpg|png';
            $config['max_size'] = '100';
            $config['max_width']  = '1024';
            $config['max_height']  = '768';


            $this->load->library('upload', $config);


            $this->upload->initialize($config);



            if ( ! $this->upload->do_upload())
            {
                $error = array('error' => $this->upload->display_errors());

                echo "<br/>";
                echo $this->upload->display_errors();
                echo "<br/> image error<br/>";
            }
            else
            {

                echo "<br/> reached <br/>";
                session_start();
                $this->membership_model->insert_images($this->upload->data(),$email);
                $data = array('upload_data' => $this->upload->data());

                echo "<br/ problem<br/>"; …
Run Code Online (Sandbox Code Playgroud)

php controller codeigniter file-upload

8
推荐指数
2
解决办法
6万
查看次数

AJAX发布JSOSN数据到空 - codeigniter

我发现了很多类似的问题,但没有人与我的问题有关,但是,这是我的AJAX请求

data = JSON.stringify(data);
url = base_url + "index.php/home/make_order";
//alert(url);

var request = $.ajax({
  url: url,
  type: 'POST',
  contentType: 'application/json',
  data: data
});
request.done(function(response){
  alert('success');
});
request.fail(function(jqXHR, textStatus, errorThrown){
  alert('FAILED! ERROR: ' + errorThrown);
});
Run Code Online (Sandbox Code Playgroud)

我的问题是当它到达PHP CI控制器$ this-> input-> post('data')到空时!

更新 这是我的数据:如AJAX请求之前所示:

data = {"sum":"2.250","info":[{"id":"6","name":"bla","price":"1.000"}]}

请帮忙.提前致谢.

ajax jquery json codeigniter

8
推荐指数
1
解决办法
3万
查看次数

在Codeigniter DBForge迁移中创建唯一字段

如何financial_year使用Codeigniter Dbforge迁移使该字段成为唯一字段?

function up() {

    $this->dbforge->add_field(array(
        'id'    =>  array(
            'type'              =>  'INT',
            'constraint'        =>  11,
            'unsigned'          =>  TRUE,
            'auto_increment'    =>  TRUE
        ),
        'financial_year'    =>  array(
            'type'              =>  'VARCHAR',
            'constraint'        =>  20
        ),
        'start_date'    =>  array(
            'type'              =>  'DATE'
        ),
        'end_date'  =>  array(
            'type'              =>  'DATE'
        ),
        'status'    =>  array(
            'type'              =>  "ENUM",
            'constraint'        =>  "'Active','Inactive'",
            'default'           =>  "Active"
        ),
        'created_on'    =>  array(
            'type'              =>  'TIMESTAMP'
        )
    ));

    $this->dbforge->add_key('id', TRUE); // add `id` as primary key

    $this->dbforge->create_table('financial_year'); …
Run Code Online (Sandbox Code Playgroud)

migration codeigniter codeigniter-2 dbforge

8
推荐指数
2
解决办法
6292
查看次数

CodeIgniter - 无法访问与您的字段名称密码对应的错误消息.(pword_check)

我是codeIgniter的新手,我刚刚陷入困境.我正在使用HMVC扩展,并在验证时收到以下错误:

无法访问与您的字段名称密码对应的错误消息.(pword_check)

任何帮助将不胜感激

码:

public function submit()
{


    $this->load->library('form_validation');

    $this->form_validation->set_rules('username', 'Username', 'required|max_length[30]|xss_clean');
    $this->form_validation->set_rules('pword', 'Password', 'required|max_length[30]|callback_pword_check|xss_clean');

    if ($this->form_validation->run() == FALSE)
    {
        $this->login();
    }
    else
    {
        echo 'Success'; die();
    }
}

public function pword_check($str)
{

    if ($str == 'test')
    {
        $this->form_validation->set_message('pword_check', 'The %s field can not be the word "test"');
        return FALSE;
    }
    else
    {
        return TRUE;
    }
}
Run Code Online (Sandbox Code Playgroud)

php validation codeigniter hmvc

8
推荐指数
2
解决办法
4万
查看次数

Codeigniter日历没有显示正确的数据和设置限制不起作用

我正在使用CodeIgniter 日历库.

我有两个表,我从我的数据库中获取日历数据.

  1. 事件表
  2. extra_events表

问题我有2个foreach循环与第二个foreach循环$query2->result_array()它不让我从数据库表中获取每天的第一个事件extra_events我也试图能够设置额外事件表的限制但不工作.

从extra_events表中

例

Test 2 | Example 2
       | Example 3
Run Code Online (Sandbox Code Playgroud)

它应该产生

Test 1 | Example 1 <!-- Missing
Test 2 | Example 2
       | Example 3
Run Code Online (Sandbox Code Playgroud)

问我怎样才能确保为$ query2-> result_array()得到所有正确的结果.

图片

在此输入图像描述

获得功能

public function get_events($year, $month) {
        $calendar = array();

        $this->db->select('*');
        $this->db->from('events');
        $this->db->where('year', $year);
        $this->db->where('month', $month);
        $query1 = $this->db->get();

        foreach ($query1->result_array() as $event) {

            $this->db->select('*');
            $this->db->from('extra_events');
            $this->db->where('events_id', $event['events_id']);
            $this->db->where('year', $year);
            $this->db->where('month', $month);
            //$this->db->limit(2);
            $query2 = $this->db->get();

            foreach …
Run Code Online (Sandbox Code Playgroud)

php codeigniter

8
推荐指数
1
解决办法
869
查看次数