我正在尝试上传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) 在发送电子邮件时,我收到了一堆这样的错误:
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) 我想用CodeIgniter测试我的控制器/模型.如何使用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了一个布尔会话变量.但是,这不起作用.
我找不到错误.
我们正在构建需要所有页面的登录信息的系统.该应用程序被设计为使用codeigniter作为Phil Sturgeon库的Restful应用程序.此库仅使用API密钥通过HTTPS连接的每个请求发送api调用来授权api调用.
即使它使用2路认证或仅使用API密钥.我正在寻找一段时间是以下场景:
服务器检查信息是否有效,然后:
API KEY应由服务器提供给客户端,作为此用户名标识的资源(这是问题??? !!!)
如何以安全的方式将API密钥发送到客户端?
如果你能给出一个例子,那将是一个很大的帮助,因为我找到并阅读了很多文章
:)
我正在尝试实现一个帖子功能,并希望从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) 我发现了很多类似的问题,但没有人与我的问题有关,但是,这是我的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"}]}
请帮忙.提前致谢.
如何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) 我是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) 我正在使用CodeIgniter 日历库.
我有两个表,我从我的数据库中获取日历数据.
问题我有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) codeigniter ×10
php ×5
file-upload ×2
ajax ×1
controller ×1
css ×1
dbforge ×1
email ×1
freebsd ×1
hmvc ×1
jquery ×1
json ×1
migration ×1
mime-types ×1
phpunit ×1
rest ×1
smtp ×1
unit-testing ×1
validation ×1