codeigniter 相关问题

CodeIgniter是由EllisLab公司创建的开源PHP Web开发框架,它已被不列颠哥伦比亚理工学院采用。该框架实现了Model-View-Controller设计模式的修改版本。有关CodeIgniter类,方法,函数,语法和用法的问题,请使用此标记。

在codeigniter中上传文件

尝试将上传的文件移动到最终目的地时遇到问题 无法使用其上传类在 codeigniter 中上传文件,上传目录也存在, 是...

回答 2 投票 0

有什么方法可以删除CodeIgniter4中的主文件夹及其子文件夹吗?

我想删除主文件夹以及其中的所有文件和子文件夹。我尝试了一个代码块,它使用 glob() 迭代所有文件,然后调用 rmdir() 删除主折叠...

回答 1 投票 0

CodeIgniter 路由和 404 自定义错误

我使用CodeIgniter。 我使用routes.php 文件根据url 的结构将某些url 路由到不同的文件。一切都运转良好。 然而,几个月前,我想我会......

回答 1 投票 0

我尝试使用bootstrap动态获取owl carousel的输出,但在codeigniter框架3.0.1版本中没有获得所需的输出

这就是我想在滑动时显示为滑块的内容,两行相应地向左或向右移动 ABC ABC <> 但我得到的在下面给出 ABC <> 当我...

回答 1 投票 0

致命错误:找不到类“CI_Controller”

当我尝试访问 xampp 服务器的本地主机时,会出现如下错误: 致命错误:找不到类“CI_Controller” C:\xampp\htdocs\系统

回答 0 投票 0

net::ERR_ABORTED 403(禁止)错误

我是 codeigniter 的新手,我面临一些问题。我使用核心 php 创建了一个商店定位器。它工作得很好。但我想将代码嵌入到 codeigniter 中。我复制了文件,当我...

回答 1 投票 0

使用 Laravel Mix 时移动公共文件夹时出现问题:我收到 404 错误

使用 Laravel Mix 运行项目时,我收到 404 并且无法访问页面。 我安装了composer 我没有创建该项目,它以前有这样的结构。 主要的 -核 -应用程序 -溃败...

回答 1 投票 0

路线不工作codeigniter

当我将welcome设置为默认控制器时,路由不起作用,默认控制器显示错误404,然后使用welcome控制器定义的所有路由都工作,但我的其他路由和url...

回答 3 投票 0

DataTable(服务器端)Ajax 使用 CodeIgniter4 错误 DataTable 未显示

所以我的任务是使用 codeigniter 4 制作一个 DataTable,并在互联网上浏览如何做到这一点,我设法在 youtube 上找到一个教程并遵循每个步骤,但出于某些原因...

回答 1 投票 0

如何在 php 中动态添加多个 WHERE 子句 [已关闭]

我有五个输入字段,即技能、地点、公司、经验和薪水。根据用户的要求,我将从数据库中获取值。我的问题是,如何使用where条件动态...

回答 2 投票 0

Codeigniter 将数组插入数据库

我在 Codeigniter 中创建了一个表单,其中包含一个使用 JavaScript 动态复制的电话号码字段。所以基本上我可以有一个或多个这样的字段。 我在 Codeigniter 中创建了一个表单,其中包含一个使用 JavaScript 动态复制的电话号码字段。所以基本上我可以有一个或多个这样的字段。 <input name="phone[]" value=""type="text"> <input name="phone[]" value=""type="text"> 然后在我的控制器中我有 $form_data = array( 'first_name' => $this->input->post('first_name'), 'last_name' => $this->input->post('last_name'), 'phone' => $this->input->post('phone[]') ); 然后我将其保存到我的数据库中 function SaveForm($form_data) { $this->db->insert('customers', $form_data); if ($this->db->affected_rows() == '1') { return TRUE; } return FALSE; } 但显然“电话”的代码是错误的,我只是不知道如何正确执行此操作。 您无法将数组保存到数据库中。您可以使用 implode() 将其转换为字符串,然后在需要时使用 explode() 将其转换回数组。就像下面这样 $phone=implode(',',$this->input->post('phone')); $form_data = array( 'first_name' => $this->input->post('first_name'), 'last_name' => $this->input->post('last_name'), 'phone' => $phone ); 或 您可以将其转换为 json 字符串,并在需要时转换回数组,如下所示: $phone = json_encode($this->input->post('phone')); 转换回数组 $phone = json_decode($phone, TRUE); 按如下方式修改你的函数,它将像魅力一样工作: function SaveForm($form_data) { $batch_data = []; foreach ($form_data as $data) { $batch_data[] = [ 'first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'phone' => $data['phone'] ]; } $this->db->insert_batch('customers', $batch_data); return $this->db->affected_rows() > 0; } 在控制器中 $phone = $_POST['phone'];//this will store data as array. Check image 02 $form_data = array( 'first_name' => $this->input->post('first_name'), 'last_name' => $this->input->post('last_name'), 'phone' => $phone,//some times it works with '$phone' ); 在模型中 function SaveForm($form_data) { $this->db->insert('customers', $form_data); if ($this->db->affected_rows() == '1') { return TRUE; } else { return FALSE; } } 已测试 图片01(我的表格) 图片02(提交后) mysql没有任何数组数据类型。所以我们不能将数组直接存储到mysql数据库中。 为此,我们必须首先使用 php serialize() 函数将数组转换为字符串,然后将其保存到 mysql 数据库中。 例如:将数组存储在数据库中的php代码 $array = array("foo", "bar", "hello", "world"); $conn=mysql_connect('localhost', 'mysql_user', 'mysql_password'); mysql_select_db("mysql_db",$conn); $array_string=mysql_escape_string(serialize($array)); 从数据库检索数组 $conn=mysql_connect('localhost', 'mysql_user', 'mysql_password'); mysql_select_db("mysql_db",$conn); $q=mysql_query("select column from table",$conn); while($rs=mysql_fetch_assoc($q)) { $array= unserialize($rs['column']); print_r($array); } 要将数组插入到数据库,请在 codeigniter 控制器中使用此程序=> $inputdata=$this->input->post(); $phone=array($inputdata['phone']); foreach($phone as $arr) { $phoneNo=$arr; $f=count($phoneNo); for($i=0;$i<$f;$i++) { $arre=[ 'phone'=>$phoneNo[$i], ]; $insertB= $this->user_model->userdata($arre); } } public function add_theme_pages(){ $page_name = $this->input->post('page'); $page_img = $this->input->post('page_img'); for($i=0; $i < count($page_name); $i++){ $pages_data = array( 'theme_id' => $this->input->post('theme_id'), 'theme_page_name' => $page_name[$i], 'theme_page_img' => $page_img[$i] ); if($this->backendM->add_theme_pages($pages_data)){ $this->session->set_flashdata('message', 'Theme Added Successfully !'); $this->session->set_flashdata('message_class', 'green'); $this->create_template(); }else{ $this->create_template(); } } }

回答 6 投票 0

CodeIgniter - 图像提交按钮不起作用

我正在使用 CI 为客户创建一个项目,我有一个提交按钮作为图像,但它似乎没有提交表单,我目前拥有的代码是。 我正在使用 CI 为客户创建一个项目,我有一个提交按钮作为图像,但它似乎没有提交表单,我目前拥有的代码是。 <input type="image" name="trialSubmit" id="trialSubmit" src="<?php echo base_url().'images/subscribe_free.jpg'; ?>" style="height:29px;width:207px;border-width:0px;" /> 我现在必须使用的代码如下 <input type="submit" name="trialSubmit" value=" Subscribe Free " id="" class="button" /> 如果有人能解释为什么它不能处理图像,那就太紧张了。 干杯, 是否适用于所有浏览器?还是IE特定的?如果您添加一个 onclick 事件只是为了测试呢? onclick="javascript:document.formidhere.submit()" 我建议使用 <input type="submit" /> 或我的偏好是使用 <button type="submit>,因为浏览器与 <input type="image" /> 不一致,只需使用以下内容设置按钮样式: button{ background:url('/images/subscribe_free.jpg') no-repeat; height:29px; width:207px; border:0; } 尝试添加 value="trialSubmit" 以获取要提交的图像。似乎对我有用。 您还可以看看这个答案是否有帮助: 图像提交按钮 **inside the view(as comerciales in my case)**, <form action= "<?php echo site_url()?>/admin/doupload" method="post" enctype="multipart/form-data" > <b> Select the image to upload( Maximum size 500 kb, jpg, jpeg): </b> <input style="color:#00A76F" type="file" name="fileToUpload" id="fileToUpload"> <div class="input-group" style="left:10%;width:85%;"> <input class="btn btn-success pull-right" style="background:#00A76F" type="submit" value="Upload Image" name="submit"> </div> </form> <div class="modal-body"> <div id="user_data"> <?php if (!empty($massage)){ echo $massage ; } ?> </div> **inside the controller define a method** public function doupload(){ $root1 = $_SERVER['DOCUMENT_ROOT'];; $target_dir = $root1."/nawaloka/uploads/"; // $target_dir = $root1."/nawaloka/application/"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); // Check if file already exists // Check file size if ($_FILES["fileToUpload"]["size"] > 500000) { $data['massage']= "Sorry, your file is too large."; $partials = array('content' => 'Admin/comerciales'); $this->template->load('template/admin_template', $partials,$data); $uploadOk = 0; } if (is_dir($target_dir) && is_writable($target_dir)) { // do upload logic here } else { echo 'Upload directory is not writable, or does not exist.'; } // Allow certain file formats if($imageFileType != "jpg" && $imageFileType != "jpeg" ) { $data['massage']= "Sorry, only JPG, JPEG files are allowed."; $partials = array('content' => 'Admin/comerciales'); $this->template->load('template/admin_template', $partials,$data); $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { $data['massage']= "Sorry, your file was not uploaded."; $partials = array('content' => 'Admin/comerciales'); $this->template->load('template/admin_template', $partials,$data); // if everything is ok, try to upload file } else { array_map('unlink', glob("/var/www/html/nawaloka/uploads/*")); if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],"/var/www/html/nawaloka/uploads/shamith.jpg")) { $data['massage']= "The image ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; $partials = array('content' => 'Admin/comerciales'); $this->template->load('template/admin_template', $partials,$data); //echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; } else { $data['massage']= "Sorry, there was an error while uploading your file."; $partials = array('content' => 'Admin/comerciales'); $this->template->load('template/admin_template', $partials,$data); } } }

回答 3 投票 0

Codeigniter 无法加载库

最初,我以为由于在 Codeigniter 中使用模块化扩展而导致加载库时出现问题。 然而我发现即使全新安装了 codeigniter 我也无法加载

回答 6 投票 0

Codeigniter 会话无法在实时服务器上运行

当打开 codeigniter 项目 localhost 时,它们正常工作并在服务器中打开,然后出现无效路径错误 遇到 PHP 错误 严重性:警告 消息:mkdir():无效路径

回答 8 投票 0

codeigniter 路由和重定向

当我输入我的基本 URL http://localhost/myproject/admin 时,它会继续将我发送到我的权限页面。 http://localhost/myproject/admin 是base_url()。 我的 core/Controller.php 是如何工作的...

回答 2 投票 0

CodeIgniter 中发起的Controller在哪里

我想知道控制器在哪里启动(我的意思是文件包含在哪里,然后加载它的类并调用它的方法)。我想知道,因为我想创造......

回答 1 投票 0

Htaccess 重定向 http>https CI3

我目前有这样一个htaccess文件,它将通配符子域(例如name.domain.com)重定向到domain.com/account/company/name。 RewriteCond %{REQUEST_FILENAME} !-f 重写条件%{

回答 1 投票 0

codeigniter更新图片上传

嗨,我正在开发一个图像上传模块,其中图像路径保存在数据库中并在预览中检索,这是我的问题我希望它编辑和更新,但我的问题是它不删除...

回答 2 投票 0

在 Codeigniter 的控制器上调用函数 B 中的函数 A

我有一个具有大约 5-6 个功能的控制器。 类 Register 扩展 CI_Controller { 公共函数索引() { // 写的一些代码 } 公共函数添加() { // 写的一些代码 } ...

回答 2 投票 0

将字符串转换为 MongoDB 中的 ObjectID

我正在使用 Codeigniter 和 MongoDB 开发 API。 在数据库的某些部分,我以 ObjectID 格式保存了图像的 ID 而不是字符串。现在我得到了一个字符串格式的 ID,我需要...

回答 10 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.